I am currently trying to run a simple hello world program in powershell using this code :
import subprocess
import sys
p = subprocess.Popen(["powershell.exe",
'C:/users/m.m/Desktop/hello.ps1'],
stdout = sys.stdout)
p.communicate()
what i'm trying to do is this; i have saved the "hello.ps1" python program with powershell extension containing print("hello, world!")
in desktop and I want to create a program that reads the file within my python files , opens them and runs those scripts in powershell after invoking python by python
command.
I have already tried the code above as suggested in here ==> Running powershell script within python script, how to make python print the powershell output while it is running, but it gives me security error.
This is the error that i get when run the code above:
C:/users/m.m/Desktop/hello.ps1 : File C:\users\m.m\Desktop\hello.ps1 cannot
be loaded because running scripts is
disabled on this system. For more information, see about_Execution_Policies
at
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ C:/users/m.m/Desktop/hello.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
The main goal is this:using python to write scripts for powershell.