title: Execute Powershell Command remotely and print the output using wmi python
body: <p>I want to execute powershell command remotely and fetch the output.
  The command is "(New-Object -c Microsoft.Update.Session).CreateUpdateSearcher().Search("IsInstalled=0").Updates|Select Title".<br>
  I have tried </p>
  
  <pre><code>import wmi
  try:
    connection = wmi.WMI(ip, user=username, password=password)
    print("connection is established")
    connection.Win32_Process.Create(CommandLine='powershell.exe /c (New-Object -c Microsoft.Update.Session).CreateUpdateSearcher().Search("IsInstalled=0").Updates|Select Title  &gt; C:\output.txt')
  except:
    print("connection failed")
  </code></pre>