title: How can I to run Windows PowerShell commands from Python?
body: <p>I want to execute the below commands from Python, but I'm not getting any output:</p>
  <pre><code>get-winevent -logname Microsoft-Windows-TerminalServices-LocalSessionManager/Operational -ComputerName $env:COMPUTERNAME | where {$_.Id -eq &quot;21&quot;}
  </code></pre>
  <p>I found some solutions as below, but they are also not running successfully:</p>
  <pre><code>subprocess.Popen('powershell.exe [get-winevent -logname Microsoft-Windows-TerminalServices-LocalSessionManager/Operational -ComputerName $env:COMPUTERNAME] | where {$_.Id -eq &quot;21&quot;}')
  </code></pre>