PowerShell Change Service Startup Type
10-11-2017
Language or Platform: Powershell
Code:
# Change Service Startup Type
# Pulls a list of computers or servers from computers.txt
# Searches for Service names in services.txt"
# Under the Select option, you can add MachineName, ServiceName, Status, StartType, etc
$startupType = 'Manual' # change to Automatic or Manual for changing Startup Type. This is only used for the Set-Service option.
$serviceList = gc C:\ManageServices\services.txt # gc is short for Get-Content
get-content C:\ManageServices\computers.txt | % {
ForEach ($service in $serviceList)
{
if ($s=get-service -computer $_ -name $service -ErrorAction SilentlyContinue)
{
$s | select MachineName, ServiceName, StartType | Set-Service -computer $_ -StartupType $startupType
#Comment above if you don't want to change Startup Type
# and you just want to check status
}
else {"The Service called $service is not located on $_"}
}
}
Back