Forum Discussion
rraghvani
2 years agoChampion Level 3
Here's an example,
function PSTest()
{
var oShell = getActiveXObject("WScript.Shell");
var oExec = oShell.Exec("powershell -Command \"C:\\Temp\\HelloWorld.ps1\"");
oExec.StdIn.Close(); // Close standard input before reading output
// Get PowerShell output
var 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 (var i = 0; i < aqString.GetListLength(strOutput); i++)
{
Log.Message(aqString.GetListItem(strOutput, i));
}
}
HelloWorld.ps1 contains just
Write-Host "Hello World"
Ensure your path is correct; use double backslash, and enclose the full path in quotes
Related Content
- 5 years ago
Recent Discussions
- 4 days ago
- 4 days ago