Build a service inventory with PowerShell
Collect a useful Windows service snapshot before making changes.
Define the inventory
Run this read-only example locally in PowerShell on Windows. The output captures service name, state, startup mode, and account. Treat account names and executable paths as internal operational data, and store exports in an approved location.
Collect a consistent snapshot
Get-CimInstance exposes service properties that are useful when comparing machines. Export-Csv produces a file you can review or compare later. This writes a new timestamped file in the current directory.
Get-CimInstance Win32_Service |
Select-Object Name, DisplayName, State, StartMode, StartName |
Sort-Object Name |
Export-Csv -Path ("services-{0}.csv" -f (Get-Date -Format yyyyMMdd-HHmmss)) -NoTypeInformationInvestigate exceptions
An automatic service being stopped is a lead, not proof of a fault: some services start on a trigger or intentionally exit. Compare the service against its intended role and inspect the Windows event logs before changing its startup mode.
Get-CimInstance Win32_Service |
Where-Object { $_.StartMode -eq "Auto" -and $_.State -ne "Running" } |
Select-Object Name, State, StartModeExtend deliberately
For multiple hosts, use an approved management endpoint and least-privilege access. Add the computer name and collection time to each record. Avoid placing passwords in scripts, and distinguish unreachable hosts from machines that returned an empty result.