Forum Discussion

ShahZaib's avatar
2 years ago

Reading powershell output

Hi I have created a PowerShell script and saved that in a file I have created the following PowerShell script to read the locked cells


$Path = 'D:\ABS\ABS.xlsx'

$Excel = New-Object -Com Excel.Application

$Workbook = $Excel.Workbooks.Open($Path)

$page = 'PLANT'

$ws = $Workbook.worksheets | where-object {$_.Name -eq $page}

$cells = $ws.Columns.Item(9).hidden return

$cells $workbook.Close($true)



I am unable to read the output from that script using test complete Following is the script

function GetProcesses()
var oExec = WshShell.Exec("powershell -File D:\ABS\Untitled1.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++)