Answer the question
In order to leave comments, you need to log in
How to call powershell scripts from python?
Good afternoon, I want to run scripts (full-fledged, large and not so) on a python powershell. Recommended subproccess
in this format. If I pass the command as an argument, it works, if the script does not work.
Execution of unsigned scripts enabled.
Tell me, please, darn
subprocess.Popen(['powershell', r'G:\test.ps1'])
Answer the question
In order to leave comments, you need to log in
in my opinion it is easy to google
https://stackoverflow.com/questions/21944895/runni...
Desktop\test.ps1:
write-output 'test'
test.py:
# -*- coding: iso-8859-1 -*-
import subprocess, sys
p = subprocess.Popen(["powershell.exe",
"C:\\Users\\<USER>\\Desktop\\test.ps1"],
stdout=sys.stdout)
p.communicate()
python test.py
test
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question