How to Configure Windows Services with PowerShell

Using Windows PowerShell, you can customize the behavior of Windows services during system startup. With a simple command, you can swiftly enable or disable services in Windows.

In this article, I will provide practical examples demonstrating how you can leverage Windows PowerShell to configure and manage Windows services, allowing you to control their startup behavior efficiently.

Advertisements

Disable Windows service via PowerShell

If you do not want to start a Windows service automatically after the next system starts, it must be deactivated before restarting. You could do this either via the graphical interface “services“ (services.msc) or use Windows PowerShell. This is particularly recommended in configuration or installation scripts. Configuration of Windows services with PowerShell.

In the following example, I disable the service “print queue (spooler)“ on one Windows server (but it also works on Windows 10). First, I query the current startup type, then change it to “disabled‘ and then check the result again by querying the launch type:

Advertisements
Get-Service -Name "spooler" | select -property name, starttype
Set-Service -Name "spooler" -StartupType Disabled
Get-Service -Name "spooler" | select -property name, starttype

As you can see from the screenshot, you will not get a success message from Windows PowerShell that the service has been deactivated with immediate effect. Likewise, if the service were previously in, the “Disabled” would have been. That’s why I queried the example before and after the status.

  How to Document System events with Powershell

If you still want to manually stop the service before shutting down, you can do so with the following command:

Advertisements
Stop-Service -Name "spooler"

Manual or Automatic – Enable Windows service

Only services with the startup setting “Automatically” or “Manually‘ can be executed. This setting, like deactivation, can also be set via PowerShell. The commands are:

Set service startup to manual

Set-Service -Name "spooler" -StartupType Manual

Service will start automatically

Set-Service -Name "spooler" -StartupType Automatic

Important: The setting “Automatic (Delayed Start)‘ cannot be configured in this way. The graphical user interface of the Management Console must continue to be used for this.

Advertisements

Start the service with Powershell.

If you have configured a service with PowerShell as above, you can then start it manually. Taking the print queue example again, the command is:

Start-Service -Name "spooler"

As you can see, configuring the services with PowerShell is very easy, and its startup type quickly changes. These commands are always extremely helpful, especially when automating administrative tasks.

Share This Article
Author
Follow:
Rohit is a certified Microsoft Windows expert with a passion for simplifying technology. With years of hands-on experience and a knack for problem-solving, He is dedicated to helping individuals and businesses make the most of their Windows systems. Whether it's troubleshooting, optimization, or sharing expert insights,