Cannot Run Powershell Script with Python
I am trying to 'Run PowerShell Script and Get the Result as Text' PYTHON code snippet that can be found here https://support.smartbear.com/viewarticle/72616/ but I am getting the error below
code snippet
def Test():
oShell = Sys.OleObject["WScript.Shell"]
oExec = oShell.Exec("powershell -command Get-Process")
oExec.StdIn.Close() # Close standard input before reading output
# Get PowerShell output
strOutput = oExec.StdOut.ReadAll();
# Trim leading and trailing empty lines
strOutput = aqString.Trim(strOutput, aqString.stAll);
# Post PowerShell output to the test log line by line
aqString.ListSeparator = "\r\n";
for i in range(0, aqString.GetListLength(strOutput)):
Log.Message(aqString.GetListItem(strOutput, i))
AttributeError
'IDispatchIndexedPropertyWrapper' object has no attribute 'Close'
Error location:
I tried to run the same code snippet using VBScript and it executed successfully.
Hello,
I would like to let everyone know that the issue has been fixed some time ago and the fix is included to TestComplete version 11.31 that has been released on Tuesday.
John, we were waiting for a case from you in order to provide the fix, but I was unable to find any requests from you. Did you contacted the Customer Care team regarding this issue?