这是我的代码
$result = Invoke-Command -Session $session -FilePath $ps1
如何获得 $ps1 给出的结果?
该函数的代码应该给出如下所示的 true false 结果:
function MyFunction{
#some code
if ($JobStatus -like "Running")
{
$result = $false
Write-Host "Gresit" -foreground Red
}
else
{
$result = $true
Write-Host "Corect" -foreground Green
}
}
使用 return 代替 Write-Host。
例如: if ($JobStatus - 就像“正在运行”) { $结果 = $假 返回“格雷西特” } 别的 { $结果 = $true 返回“正确” } }