孤独海岸线 发表于 2018-9-2 12:38:54

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]
查看完整版本: powershell 中if elseif 的用法