Home > Net >  How would you programmatically report which Windows Services are not running?
How would you programmatically report which Windows Services are not running?

Time:05-06

Given:

  • PowerShell 5.1 or above
  • Cmdlet Get-Service
  • Windows OS
  • Windows Services

How would you programmatically report if a Window Services is Stopped?

enter image description here

CodePudding user response:

If you want to start them all, use the Where-Object cmdlet to filter the list of services so you only get those that:

  • Are not running, and
  • Are not disabled

Then pipe the resulting set of services to Start-Service:

Get-Service |Where-Object Status -ne Running |Where-Object StartType -ne Disabled |Start-Service
  • Related