powershell 中if elseif 的用法
Get-Service | Sort-Object Status -Descending | ForEach-Object `{
if($_.status -eq "stopped")
{
Write-Host $_.name $_.status -ForegroundColor Red
}
elseif($_.Status -eq "running")
{
Write-Host $_.name $_.status -ForegroundColor Green
}
else
{
Write-Host $_.name $_.Status -ForegroundColor Yellow
}
}
页:
[1]