def _pshell_json(cmd, cwd=None):
 cmd = 'Import-Module ServerManager; {0}'.format(cmd)
 if ('convertto-json' not in cmd.lower()):
  cmd = '{0} | ConvertTo-Json'.format(cmd)
 log.debug('PowerShell: {0}'.format(cmd))
 ret = __salt__['cmd.shell'](cmd, shell='powershell', cwd=cwd)
 try:
  ret = json.loads(ret, strict=False)
 except ValueError:
  log.debug('Json not returned')
 return ret

def _pshell_json ( cmd , cwd = None ) : cmd = 'Import-Module ServerManager; {0}' . format ( cmd ) if ( 'convertto-json' not in cmd . lower ( ) ) : cmd = '{0} | ConvertTo-Json' . format ( cmd ) log . debug ( 'PowerShell: {0}' . format ( cmd ) ) ret = __salt__ [ 'cmd.shell' ] ( cmd , shell = 'powershell' , cwd = cwd ) try : ret = json . loads ( ret , strict = False ) except ValueError : log . debug ( 'Json not returned' ) return ret
execute the desired powershell command and ensure that it returns data in json format and load that into python .