I had a requirement where I need to trigger an existing PowerShell script from Python. The PowerShell script is to download a file from SharePoint.
I wanted to have the output of the PowerShell script within Python script output.
It’s quite easy to do this using subprocess and sys modules.
import subprocess, sys
p = subprocess.Popen(["powershell.exe",
"C:\\Project\\downloadSharePointFile.ps1"],
stdout=sys.stdout)
p.communicate()