I wrote a PowerShell script which works fine when I run that from cmd as
powershell . C:\\scripts\\Azure.ps1; Review-Subscriptions -args xyz .\\output xxx-xxx-xxx 2017-23-07-01-04
path = "C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe"
script_path = "C:\\scripts\\Azure.ps1"
function_name = "Review-Subscriptions"
subscription_id = 'xxx-xxx-xxx'
file_path = '.\\output"'
now = datetime.datetime.now().strftime("%Y-%d-%m-%H-%M")
cmd = '. %s; %s -args xyz %s %s %s' % \
process = subprocess.Popen(
[path, '-ExecutionPolicy', 'Unrestricted',
], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
cmd = 'Import-Module AzureRM; . %s; %s( %s, %s, "%s")' % \
Powershell modules were installed in the x64 system.
I had to just install Pythonx64 and use that to communicate with PowerShell.
I think the reason is that, when we use Pythonx86 then it communicates with Powershell by means of an x86 process, where as in the case Pyhonx64, it communicates with PowerShell using an x64 process.