I'm attempting to use python to trigger a Powershell script which runs fine when I run it from my connection to Powershell (which defaults to 'run as administrator). However, when launched from a python interface, it give me a permission denied error. Here's a snippet of some of the code I'm attempting to run which fails when launched by Python but not when launched through a powershell prompt.
elif "!ExchangeCheck" in message:
response = subprocess.Popen("powershell -ExecutionPolicy Unrestricted -File C:\users\.....\code\servicecheck.ps1", shell=True, stdout=subprocess.PIPE).stdout.read()
status = "Exchange services are: \n"
for line in thing:
if "Microsoft Exchange" in response:
status += line
print status
Hoping to find a way to use Popen or something like paramiko for powershell where it will attempt to 'run as administrator' or at least use my native permissions when it attempts to run?
UPDATE: I have verified that my python script is running as an admin user.
UPDATE 2: I think a solution would be to run a script using the runas command to accretive the desired goal but I don't know if that is 'good' way to do things, it seems less than ideal.