I couldn't find much information on this unfortunately, but I wish to run a powerShell script from a python file I've written. I want the user to actually see the powerShell script being run and the user can enter inputs that the powerShell script requires from python. I am using pyCharm as an IDE.
When I run the script to call this powerShell script, it gives me this error:
File "C:\TestAutomation\eFuse\eFuse.ps1", line 19
SyntaxError: Non-ASCII character '\xc2' in file C:\Test\eK\eK.ps1 on line 19, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
Here is the relevant part of the code:
elif switch_result == "eTool":
subprocess.call(['python', 'C:\\TestAutomation\\eFuse\\eFuse.ps1'], stdout=sys.stdout)
This elif statement is a part of other if/elif statements that run other python files using the subproccess module, but for some reason I can't get this powerShell file to be run. Any advice is appreciated. Thank you
Larry Song :
First, you should already know .py file's interpreter is python.exe\n\nSo, it's easy to understand .ps1 file's interpreter is powershell.exe, not python.exe\n\nI just copy & paste from yours, your code should look like following,\n\nsubprocess.call('powershell.exe -File \"C:\\\\TestAutomation\\\\eFuse\\\\eFuse.ps1\"', stdout=sys.stdout)\n\n\nDetails about powershell.exe -?",
2019-06-26T00:20:12