# SCRIPT: Check-StoppedAutoServices.ps1
<#
.SYNOPSIS
Retrieves all Windows services set to 'Automatic' start mode that are currently 'Stopped'.
.DESCRIPTION
This script is useful for identifying services that should be running automatically
but have failed or been stopped manually, potentially indicating a system issue.
It excludes 'Disabled' and 'Manual' services.
#>
$StoppedAutoServices = Get-Service | Where-Object {
$_.Status -eq "Stopped" -and $_.StartType -eq "Automatic"
}
# Check if any services were found
if ($StoppedAutoServices.Count -gt 0) {
Write-Host "🚨 The following services are set to 'Automatic' but are currently 'Stopped':" -ForegroundColor Red
Write-Host "--------------------------------------------------------------------------------"
# Display a table with Service Name, Display Name, and Status
$StoppedAutoServices | Select-Object Name, DisplayName, Status, StartType | Format-Table -AutoSize
# Optional: Log the results to a file
$LogFile = "C:\Service_Monitor\Stopped_Auto_Services_$(Get-Date -Format 'yyyyMMdd_HHmmss').log"
$StoppedAutoServices | Select-Object Name, DisplayName, Status, StartType | Out-File $LogFile
Write-Host "`nResults also saved to: $LogFile" -ForegroundColor Yellow
} else {
Write-Host "✅ All services set to 'Automatic' are currently running." -ForegroundColor Green
}
No comments:
Post a Comment