This PowerShell script provides a quick way to check the status of critical services on a Windows server. It is designed for system administrators who need to ensure that essential services are running smoothly. With a focus on reliability, this script integrates well with ServerEngine, allowing users to maintain optimal performance and troubleshoot issues more effectively. By receiving automated reports, administrators can promptly address any service interruptions.
powershell
param (
[string[]]$servicesToMonitor = @("wuauserv", "bits", "spooler"),
[string]$reportFilePath = "C:\ServiceStatusReport.txt"
)
$serviceStatusReport = @()
foreach ($service in $servicesToMonitor) {
$serviceInfo = Get-Service -Name $service -ErrorAction SilentlyContinue
if ($serviceInfo) {
$status = $serviceInfo.Status
$serviceStatusReport += "Service: $service | Status: $status"
} else {
$serviceStatusReport += "Service: $service | Status: Not Found"
}
}
# Output the report to a file
$serviceStatusReport | Out-File -FilePath $reportFilePath
Write-Output "Service status report has been generated at $reportFilePath."Run it across your fleet
This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.
More in Monitoring & Health
Disk Space Cleanup and Report Script
2025-01-14User Account Status Reporting Script
2025-01-13Automated Disk Space Monitoring Script
2025-01-13Monitor System Performance with PowerShell
2025-01-12Automating System Health Check with PowerShell
2025-01-05Automate System Performance Monitoring with PowerShell
2024-12-30Ready when you are.
Try ServerEngine free for 7 days.