0
我試圖執行一個sript運行exe文件,獲取輸出,通過輸出搜索,然後如果真做soemthing:POWERSHELL:管道exe文件輸出到可變
$output = cmd /c file.exe additionalvariables --batch |
write-host |
where-object($_ -eq "Finished with Success") #finished with success does not work
if (-eq "Finished with Success") # I need to perform a check
{
"Command executed"
$tcp.Dispose()
Exit 0
}
else
{
"There is an issue with file.exe additionalvariables command"
EXIT 1
$tcp.Dispose()
}
所以成品成功在第1行不起作用,你知道如何檢查陳述嗎? if (-eq "Finished with Success")
。
什麼是$ LASTEXITCODE的.exe文件完成後的價值? – lit
輸出結果如何?舉個例子 –
'where-object($ _ -eq「Finished with Success」)'應該是'where-object {$ _ -eq「Finished with Success」}'''write-host' should not be used as you正在將數據發送到另一個流。只要刪除管道的那一部分,然後再試一次。 – Matt