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

    }

}


你可能感兴趣的:(status,running,Yellow,stopped)