def _exec_query_ps(cmd, fields):
 if (not WINDOWS):
  return
 ps = sp.Popen((([conf.prog.powershell] + cmd) + ['|', ('select %s' % ', '.join(fields)), '|', 'fl']), stdout=sp.PIPE, universal_newlines=True)
 l = []
 for line in ps.stdout:
  if (not line.strip()):
   continue
  sl = line.split(':', 1)
  if (len(sl) == 1):
   l[(-1)] += sl[0].strip()
   continue
  else:
   l.append(sl[1].strip())
  if (len(l) == len(fields)):
   (yield l)
   l = []

def _exec_query_ps ( cmd , fields ) : if ( not WINDOWS ) : return ps = sp . Popen ( ( ( [ conf . prog . powershell ] + cmd ) + [ '|' , ( 'select %s' % ', ' . join ( fields ) ) , '|' , 'fl' ] ) , stdout = sp . PIPE , universal_newlines = True ) l = [ ] for line in ps . stdout : if ( not line . strip ( ) ) : continue sl = line . split ( ':' , 1 ) if ( len ( sl ) == 1 ) : l [ ( - 1 ) ] += sl [ 0 ] . strip ( ) continue else : l . append ( sl [ 1 ] . strip ( ) ) if ( len ( l ) == len ( fields ) ) : ( yield l ) l = [ ]
execute a powershell query .