This article explains how to set a service startup disabled state on windows computer remotely using Powershell script, one can also use the same script stop the service on multiple remote computers.
When you want to change service startup we must stop the service first on a desktop computer or a server, we generally open the service console (services.msc) and find the name of service and we stop and change startup to disable, it’s manual if you want to do the same for more computers it is difficult to log in to each server and stop the service and change the startup, here in this article I will explain how to stop a service and set service state to disabled using the simple Powershell script…
Powershell Set-Service
This PowerShell command sets specified service to automatic, delayed, stoped, and system depending on the need we have to choose the option, in our case, we going to disabled the startup type.
As I said earlier we need to stop service first to set the startup service to disabled, and let’s take the service name Adobe Acrobat Update and stop it,
Stop-Service -Name AdobeARMservice -force
Let’s get the status of this service.
PS C:\Windows\system32> get-Service -Name AdobeARMservice Status Name DisplayName ------ ---- ----------- Stopped AdobeARMservice Adobe Acrobat Update Service
See the Service is stopped.
Now let’s disable the service startup
Set-Service -Name AdobeARMservice -StartupType Disabled
# The code disables the adobeARMservcie startup
Disable service startup on multiple computer
We need to create a file for storing all the servers or multiple machines list, I named it as Allservers.txt for and saved it in my local machine c:\temp\Allserve.txt
$Allserver = Get-Content -Path "C:\temp\AllServer.txt"
foreach ($server in $allserver)
{
Write-Host "Currently the script is stopping the serivce on" $server
Invoke-Command -ComputerName $server -ScriptBlock {Get-Service -Name AdobeARMservice | Stop-Service -Force}
Write-Host "Currently the script is changing startup serivce on" $server
Invoke-Command -ComputerName $server -ScriptBlock {Set-Service -Name AdobeARMservice -StartupType Disabled }
}
The above powershell code stops the service first if it is running then sets the service startup to disabled state.
One should have admin rights to execute this script on remote computers, generally, system admins have privilege access to computers, if not one will run into permission or access denied issues, make sure you have admin rights on the remote computers.
Thank you for reading this article, if you have any questions please let us know.
Thank you for visiting my site, for any scripts in these articles you are testing please make sure you have tested this script in our lower environment before you run in production.
Leave a Reply Cancel reply