Skip to content

Instantly share code, notes, and snippets.

@st1vms
Created February 26, 2026 18:44
Show Gist options
  • Select an option

  • Save st1vms/db493ea7f32117679bdc12e2446c8e9e to your computer and use it in GitHub Desktop.

Select an option

Save st1vms/db493ea7f32117679bdc12e2446c8e9e to your computer and use it in GitHub Desktop.
Save&Restore Windows Disabled Services
Save&Restore Windows Disabled Services
$myList = Import-Csv "$env:USERPROFILE\Desktop\DisabledServices.csv"
foreach ($item in $myList) {
$serviceName = $item.Name
# Check if the service actually exists before disabling it
if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) {
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\$serviceName" -Name "Start" -Value 4
Write-Host "Disabled service: $serviceName" -ForegroundColor Green
} else {
Write-Host "Skipping service: $serviceName (not found)" -ForegroundColor Red
}
}
Get-Service -ErrorAction SilentlyContinue | Where-Object {$_.StartType -eq 'Disabled'} | Select-Object Name, DisplayName | Export-Csv -Path "$env:USERPROFILE\Desktop\DisabledServices.csv" -NoTypeInformation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment