|
This list is not yet exhaustive.
This script will attempt to start any services listed which are not running. Copy to Clipboard
# Define the list of essential services for normal usage
$EssentialServices = @(
"Dhcp", # DHCP Client (Networking)
"Dnscache", # DNS Client (Networking)
"netprofm", # Network List Service
"AudioSrv", # Windows Audio
"AudioEndpointBuilder",
"wuauserv", # Windows Update
"PlugPlay" # Plug and Play
)
Write-Host "--- Starting Windows Service Health Check ---" -ForegroundColor Cyan
foreach ($ServiceName in $EssentialServices) {
$Service = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
if ($null -eq $Service) {
Write-Host "Warning: Service '$ServiceName' not found on this system." -ForegroundColor Yellow
}
else {
if ($Service.Status -eq "Running") {
Write-Host "Check Passed: $($Service.DisplayName) is running." -ForegroundColor Green
}
else {
Write-Host "Alert: $($Service.DisplayName) is $($Service.Status). Attempting to start..." -ForegroundColor Red
try {
Start-Service -Name $ServiceName -ErrorAction Stop
# Pause for 1 second to allow the service to initialize
Start-Sleep -Seconds 5
# Refresh the service object to get the latest status
$Service.Refresh()
if ($Service.Status -eq "Running") {
Write-Host "Successfully started $($Service.DisplayName). Current Status: Running" -ForegroundColor Green
}
else {
Write-Host "Attempted to start $($Service.DisplayName), but current status is: $($Service.Status)" -ForegroundColor Yellow
}
}
catch {
Write-Host "Failed to start $($Service.DisplayName). Error: $($_.Exception.Message)" -ForegroundColor DarkRed
}
}
}
}
Write-Host "--- Check Complete ---" -ForegroundColor Cyan
|