我正在尝试执行一个 sript 来运行 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()
}
所以finished with success在第1行不起作用,你知道如何检查if语句吗?if ( -eq "Finished with Success")
.