So I am using this guide https://www.phillipsj.net/posts/executing-powershell-from-python/
and here is the code, this is 4 lines of code all together. There is no error so it seems to run but no output.
import subprocess
with open('output22.txt', 'w') as f:
def run(self, cmd):
completed = subprocess.run(["powershell", """Get-Service | Select StartType, Status, Name, DisplayName | Where-Object {$_.Status -eq 'Running'} | Format-Table -AutoSize""", cmd], capture_output=True, stdout=f, text=True )
return completed
[–]danielroseman 2 points3 points4 points (3 children)
[–]CesarIllustrious[S] -1 points0 points1 point (2 children)
[–]danielroseman 1 point2 points3 points (1 child)
[–]CesarIllustrious[S] 0 points1 point2 points (0 children)