How to restore default services in Windows 8 (PowerShell)
Introduction
The goal of this script is to restore startup type and status of default services in Windows 8.
Scenarios
Sometime due to some software or personal reason, system default services startup type and status will be changed. This script is to restore the services to default startup type and status.
Script
Step 1: Right click the script and select Run with administrator.
Step 2: Then it will restore the service to default.
Note Please do not delete or move the two CSV files in the script root folder.
Here are some code snippets for your reference:
foreach($service in $DelayCol)
{
try
{
Write-Progress -Activity "Set Service" -PercentComplete $($i/$ServiceCol.Count*100) -CurrentOperation "Set service $($service.Name)"
if($service.Status -eq "Running")
{
$status = "Running"
}
Else
{
$status ="Stopped"
}
Set-Service -Name $service.Name -Status $status -ErrorAction SilentlyContinue
sc.exe config $service.Name start= delayed-auto | Out-Null
$i ++
}
catch
{
Write-Error $_
}
}
}
Else
{
Write-Error "Not find the DelayedautoService.csv."
}
foreach($service in $DelayCol) { try { Write-Progress -Activity "Set Service" -PercentComplete $($i/$ServiceCol.Count*100) -CurrentOperation "Set service $($service.Name)" if($service.Status -eq "Running") { $status = "Running" } Else { $status ="Stopped" } Set-Service -Name $service.Name -Status $status -ErrorAction SilentlyContinue sc.exe config $service.Name start= delayed-auto | Out-Null $i ++ } catch { Write-Error $_ } } } Else { Write-Error "Not find the DelayedautoService.csv." }
Prerequisite
Windows 8 or higher version
Microsoft All-In-One Script Framework is an automation script sample library for IT Professionals. The key value that All-In-One Script Framework is trying to deliver is Scenario-Focused Script Samples driven by IT Pros' real-world pains and needs. The team is monitoring all TechNet forums, IT Pros' support calls to Microsoft, and script requests submitted to TechNet Script Repository. We collect frequently asked IT scenarios, and create script samples to automate the tasks and save some time for IT Pros. The team of All-In-One Script Framework sincerely hope that these customer-driven automation script samples can help our IT community in this script-centric move.