ServiceStatus -Servers "Machine1", "machine2", "machine3"
workflow ServiceStatus
{
param([string[]]$servers)
foreach -Parallel ($server in $servers)
{
Write-Host "Chekcing status in $server..." -ForegroundColor black -BackgroundColor green
Get-Service W3SVC -ComputerName $server | Format-Table Name,Status,MachineName -AutoSize
if(!$?)
{
Out-File $FileName1 -Append -InputObject $server -Encoding ascii
}
}
}
我尝试让foreach
并行执行,但它给了我一个“foreach 循环附近的语法错误”错误。