Producing an Exception Report

To produce a summary report of the service configuration information you have identified, you must count each service and evaluate its start mode. If the service starts with a user-defined account, you'll need to record that information as well. In the EvaluateServicesAndCount.ps1 script, use the Get-WmiObject cmdlet to retrieve the Win32_Service class and store the resulting object in the $objWMIService variable.

Use the foreach statement and walk through the collection services. Use two switch statements to parse through the object. In the first switch statement, look for startmode. If the startmode is set to auto, you increment the $a counter variable (short for auto) and add its name to the $auto variable used ...

Get Windows PowerShell™ Scripting Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.