On this page

Managing Windows Services with PowerShell

Updated on June 17, 2026

Enrico Hochkoeppler Profile

By Enrico Hochkoeppler

Web Developer & TutoriaLibre Founder

Windows services are background processes that run without a user interface, starting automatically with the operating system or on demand. PowerShell provides a dedicated set of five cmdlets—Get-Service, Start-Service, Stop-Service, Restart-Service, and Set-Service—that give administrators complete programmatic control over service discovery, state changes, and configuration. All service-management operations require an elevated PowerShell session. This guide explains each cmdlet in full, covering local and remote usage, common automation patterns, dependency handling, and troubleshooting techniques.


Querying Services with Get-Service​

The Get-Service cmdlet retrieves objects that represent Windows services on a local or remote computer. It returns all services by default, including both running and stopped services, and exposes properties such as the short name, display name, current status, service type, and startup configuration.

Listing All Services​


Get-Service

This command returns every service installed on the system. Each result is a System.ServiceProcess.ServiceController object. The most frequently used properties are Name (the registry key name), DisplayName (the user‑friendly name shown in the Services MMC snap‑in), Status (Running, Stopped, or Paused), ServiceType (e.g., Win32OwnProcess), and CanStop (a Boolean that indicates whether the service can be stopped programmatically).

Filtering by Service Name​


Get-Service -Name "wuauserv"

Get-Service -Name "win*"

Get-Service -Name "wuauserv", "Spooler"

The -Name parameter accepts wildcard characters (* and ?). The first command retrieves the Windows Update service by its exact short name. The second command lists every service whose name begins with "win". The third command retrieves two specific services in a single call. When you use multiple names, PowerShell processes them in the order given.

Filtering by Display Name​


Get-Service -DisplayName "*update*"

Get-Service -DisplayName "Windows Update"

Display names are more readable than service names but are often longer and include spaces. The first command returns all services that contain "update" anywhere in their display name. The second command matches the exact display name of the Windows Update service. This approach is helpful when you know the name that appears in the graphical Services console.

Filtering by Status​


Get-Service | Where-Object { $_.Status -eq "Running" }

Get-Service | Where-Object Status -eq "Stopped"

Get-Service | Where-Object { $_.Status -ne "Running" }

The Where-Object cmdlet filters the service objects based on property values. The first command lists only running services. The second uses the simplified syntax (omitting the script block braces) for equality checks. The third command returns all services that are not running, which includes Stopped and Paused states.

Sorting Services​


Get-Service | Sort-Object Status, Name

Get-Service | Sort-Object DisplayName

The Sort-Object cmdlet reorders the service list. The first command groups services by status first (Running, Stopped, Paused) and then alphabetically by the short name within each group. The second command sorts purely by the display name, which is often more meaningful for human readers.

Understanding Service Dependencies​


(Get-Service -Name "LanmanWorkstation").DependentServices

(Get-Service -Name "LanmanWorkstation").RequiredServices

Services can depend on other services. The DependentServices property returns a collection of services that cannot run without the specified service. The RequiredServices property returns the services that the specified service itself depends on. Checking these properties before stopping a service prevents unintended disruptions, because stopping a service also stops its dependents.

Inspecting Service Objects​


$svc = Get-Service -Name "Spooler"

$svc | Get-Member

$svc.Status

$svc.CanStop

$svc.ServiceType

$svc.StartType

The Get-Member command reveals all properties and methods available on the service object. The subsequent lines access specific properties: Status returns the current state, CanStop indicates whether a stop operation is permitted, ServiceType describes the process model, and StartType shows whether the service starts automatically, manually, or is disabled.

Exporting Service Information​


Get-Service | Select-Object Name, DisplayName, Status, StartType |

    Export-Csv -Path "C:\Reports\services.csv" -NoTypeInformation

This pipeline selects four key properties from every service and writes them to a CSV file. The -NoTypeInformation parameter suppresses the type header that Export-Csv normally includes, making the output cleaner for import into spreadsheets or reporting tools.


Starting Services with Start-Service​

Start-Service sends a start message to the Windows Service Controller for each specified service. If the service is already running, the cmdlet does nothing and does not throw an error.

Basic Usage​


Start-Service -Name "wuauserv"

Start-Service -DisplayName "Windows Update"

Both commands achieve the same result. The first uses the short name, the second uses the display name. The cmdlet waits for the service to reach the Running state before returning control to the shell.

Starting and Capturing Output​


Start-Service -Name "Spooler" -PassThru

The -PassThru parameter forces Start-Service to output the updated service object after the start operation completes. This is useful when you need to verify the new status or chain additional operations on the same object.

Handling Disabled Services​


Set-Service -Name "tlntsvr" -StartupType Manual

Start-Service -Name "tlntsvr"

A service whose startup type is Disabled cannot be started directly. The first command changes its startup type to Manual, and the second command starts it. Without this two‑step process, Start-Service returns an error.

Using WhatIf for Testing​


Start-Service -DisplayName "*remote*" -WhatIf

The -WhatIf parameter shows which services would be started without actually performing the operation. This safe‑testing mechanism is available on all service‑control cmdlets and is invaluable when the wildcard might match unintended services.


Stopping Services with Stop-Service​

Stop-Service halts a running service. If the service is already stopped, the cmdlet completes without error.

Basic Usage​


Stop-Service -Name "wuauserv"

Stop-Service -DisplayName "Windows Update"

These commands stop the Windows Update service. The cmdlet sends a stop request and waits for the service to transition to the Stopped state.

Forcing a Stop​


Stop-Service -Name "Spooler" -Force

The -Force parameter stops the service and also stops any dependent services. Without -Force, Stop-Service terminates the service only if it has no dependents. Use -Force cautiously, especially on production systems, because stopping a dependent service may break functionality that relies on it.

Stopping Services from the Pipeline​


Get-Service -Name "Spooler" | Stop-Service

Get-Service | Where-Object { $_.Status -eq "Running" -and $_.Name -like "wmi*" } | Stop-Service

The pipeline sends service objects directly to Stop-Service. The first command stops a single service. The second command filters for running services whose name starts with "wmi" and stops all of them in one operation.


Restarting Services with Restart-Service​

Restart-Service performs a stop operation followed immediately by a start operation. If the service is already stopped, it is started without an error.

Basic Usage​


Restart-Service -Name "Spooler"

Restart-Service -Name "wuauserv"

These commands restart the Print Spooler and Windows Update services respectively. The cmdlet waits for the stop to complete before initiating the start, ensuring a clean restart.

Restarting with Force​


Restart-Service -Name "Spooler" -Force

The -Force parameter applies to the stop phase of the restart, forcing the service and its dependents to stop. This is equivalent to Stop-Service -Force followed by Start-Service.

Restarting Multiple Services​


Get-Service -Name "wmi*" | Restart-Service

Get-Service -Name "net*" | Where-Object { $_.Status -eq "Stopped" } | Restart-Service

The first command restarts every service whose name starts with "wmi". The second command filters for stopped network services and restarts them. Restarting a stopped service simply starts it, so this pattern is a convenient way to bring a group of services online.


Configuring Services with Set-Service​

Set-Service modifies the properties of a service, including its startup type, display name, description, and running status. Unlike the control cmdlets, Set-Service changes the underlying configuration, not just the runtime state.

Changing Startup Type​


Set-Service -Name "Spooler" -StartupType Automatic

Set-Service -Name "Spooler" -StartupType Manual

Set-Service -Name "SysMain" -StartupType Disabled

The -StartupType parameter accepts three values:

This changes the service's registry settings. The change does not immediately affect the running state; you must separately start or stop the service if you need an immediate state change.

Changing Display Name​


Set-Service -Name "LanmanWorkstation" -DisplayName "LanMan Workstation"

This updates the user‑friendly name shown in the Services console. The display name is for identification only; it does not affect the service's functionality.

Changing Service Description​


Set-Service -Name "BITS" -Description "Transfers files in the background using idle network bandwidth."

The description appears in the Services console's description column and provides context for administrators. To verify the updated description, use the Win32_Service WMI class:


Get-CimInstance Win32_Service -Filter 'Name = "BITS"' | Format-List Name, Description

Starting or Stopping with Set-Service​


Set-Service -Name "WinRM" -Status Running -PassThru

Set-Service -Name "WinRM" -Status Stopped -PassThru

The -Status parameter allows Set-Service to change the runtime state. Running starts the service, and Stopped stops it. The -PassThru parameter returns the updated service object so that you can inspect the final status.


Managing Services on Remote Computers​

Remote service management depends on the PowerShell version you are running.

PowerShell 5.1 and Earlier​


Get-Service -ComputerName "Server01", "Server02" -Name "wuauserv"

In PowerShell 5.1 and earlier, the *-Service cmdlets include a -ComputerName parameter that accepts a single computer name or an array. This parameter uses the RPC protocol and does not require PowerShell Remoting to be enabled.

PowerShell 6.0 and Later​


Invoke-Command -ComputerName "Server02" -ScriptBlock { Get-Service -Name "wuauserv" }

Invoke-Command -ComputerName "Server01", "Server02" -ScriptBlock { Restart-Service -Name "Spooler" -Force }

Starting with PowerShell 6.0, the -ComputerName parameter was removed from *-Service cmdlets. Remote management now relies on PowerShell Remoting (WinRM) with Invoke-Command. The ScriptBlock runs the same service commands you would use locally, but on the target computers. The output includes the PSComputerName property to identify the source of each result.


$computers = @("SrvA", "SrvB", "SrvC")

Invoke-Command -ComputerName $computers -ScriptBlock {

    Get-Service -Name "Spooler"

} | Select-Object PSComputerName, Name, Status

This example restarts the Print Spooler on three servers and returns the name, status, and originating computer for each.

Remote Permissions​

Remote service operations require that the user account has administrative rights on the target computer. If you encounter "access denied" errors, verify that your account is a member of the target's Administrators group. In domain environments, this typically means using a domain admin or a delegated service account. For fine‑grained control, tools such as sc.exe or SubInACL.exe can modify service‑level permissions, but these are outside the scope of PowerShell's native cmdlets.


Batch Operations and Scripting​

Managing Multiple Services with Arrays​


$services = @("wuauserv", "Spooler", "BITS")

$services | ForEach-Object { Restart-Service -Name $_ -ErrorAction SilentlyContinue }

This defines an array of service names and iterates over them using ForEach-Object. The -ErrorAction SilentlyContinue suppresses errors for services that do not exist or cannot be restarted, allowing the loop to continue.

Setting Startup Type for Multiple Services​


$services = @("wuauserv", "BITS", "appidsvc")

$services | ForEach-Object { Set-Service -Name $_ -StartupType Manual }

This sets three services to manual startup in a single pass. The pattern is identical to the restart example, with a different cmdlet and parameter.

Checking Service Existence Before Operation​


$serviceName = "wuauserv"

if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) {

    Restart-Service -Name $serviceName

} else {

    Write-Host "Service '$serviceName' does not exist."

}

The if statement attempts to retrieve the service. If Get-Service succeeds, the service exists, and the script restarts it. If Get-Service fails (because the service is missing), the -ErrorAction SilentlyContinue suppresses the error message, and the script writes a notification.

Finding Automatic Services That Are Not Running​


Get-Service | Where-Object {

    $_.StartType -eq "Automatic" -and $_.Status -ne "Running"

} | Select-Object Name, DisplayName, Status

This query is a common health check after a system reboot. It identifies services that are configured to launch automatically but are not currently running, which often indicates a startup failure that requires investigation.

Starting All Stopped Services That Can Be Started​


Get-Service | Where-Object { $_.Status -eq "Stopped" -and $_.CanStart } | Start-Service

The CanStart property is a Boolean that indicates whether the service is capable of being started (i.e., it is not disabled and its startup type is not Disabled). This pipeline safely starts every stoppable service that is not already running.

Auto‑Restore Monitoring Script​


$serviceName = "wuauserv"

$maxAttempts = 3

$attempt = 0



while ($attempt -lt $maxAttempts) {

    $svc = Get-Service -Name $serviceName -ErrorAction SilentlyContinue

    if ($svc.Status -eq "Running") { break }

    $attempt++

    Start-Sleep -Seconds 30

}



if ($attempt -eq $maxAttempts) {

    Start-Service -Name $serviceName

    "$(Get-Date): $serviceName restarted" | Out-File "C:\Logs\ServiceWatch.log" -Append

}

This script implements a simple watchdog. It checks the specified service up to three times, waiting 30 seconds between checks. If the service is not running after all attempts, it starts the service and logs the restart event. This pattern is suitable for scheduled tasks that monitor critical services.


Common Pitfalls and Troubleshooting​

Administrator Privileges​

All service operations that modify state or configuration require an elevated PowerShell session. Running PowerShell as a standard user will cause errors when using Start-Service, Stop-Service, Restart-Service, or Set-Service. The error message typically reads "Access is denied" or "Service control request failed." Launch PowerShell by right‑clicking and selecting "Run as administrator" to avoid this.

Service Name vs. Display Name​

Many services have short names that differ significantly from their display names. For example, the Print Spooler has the short name "Spooler". Using a display name with a cmdlet that expects the -Name parameter (which defaults to the short name) will fail unless you explicitly use -DisplayName. Always verify the correct name:


Get-Service -DisplayName "*print*" | Select-Object Name, DisplayName

Services with Dependencies​

Attempting to stop a service that has dependents without using -Force will produce an error. Check dependencies before stopping:


(Get-Service -Name "LanmanWorkstation").DependentServices

If the list is not empty, consider whether stopping the service is safe, or use -Force to stop the dependents as well.

Disabled Services Cannot Be Started​

A service with StartupType set to Disabled will reject any start request. The error message clearly states that the service is disabled. The solution is to change the startup type to Manual or Automatic before starting.

Using WhatIf to Prevent Mistakes​

The -WhatIf parameter is supported by all service‑control cmdlets. Use it to preview which services would be affected by a command that uses wildcards:


Stop-Service -Name "win*" -WhatIf

Restart-Service -Name "spooler" -WhatIf

Set-Service -Name "BITS" -StartupType Disabled -WhatIf

This output shows the exact service names without making any changes, reducing the risk of unintended disruptions.


Summary Table​

TaskCmdletExampleList all servicesGet-Service``Get-ServiceFind services by short nameGet-Service -Name``Get-Service -Name "win*"Find services by display nameGet-Service -DisplayName``Get-Service -DisplayName "*update*"Filter by statusGet-Service + Where-Object``Get-Service | Where-Object Status -eq "Running"Start a serviceStart-Service``Start-Service -Name "wuauserv"Stop a serviceStop-Service``Stop-Service -Name "wuauserv"Force stop a serviceStop-Service -Force``Stop-Service -Name "Spooler" -ForceRestart a serviceRestart-Service``Restart-Service -Name "Spooler"Set startup type to AutomaticSet-Service -StartupType``Set-Service -Name "BITS" -StartupType AutomaticSet startup type to ManualSet-Service -StartupType``Set-Service -Name "BITS" -StartupType ManualDisable a serviceSet-Service -StartupType``Set-Service -Name "SysMain" -StartupType DisabledChange display nameSet-Service -DisplayName``Set-Service -Name "LanmanWorkstation" -DisplayName "New Name"Change service descriptionSet-Service -Description``Set-Service -Name "BITS" -Description "New description"Manage remote services (PS 5.1)Get-Service -ComputerName``Get-Service -ComputerName "Server01"Manage remote services (PS 6+)Invoke-Command``Invoke-Command -ComputerName "Server01" -ScriptBlock { Get-Service }Preview changes-WhatIf``Stop-Service -Name "Spooler" -WhatIf

The five core service cmdlets form a complete toolkit for Windows service administration. From simple health checks to complex multi‑server automation, these commands replace manual point‑and‑click operations with reliable, repeatable, and scriptable processes.

Found this helpful? Share the knowledge...

... or support this project to keep it alive!

Buy Me a Coffee

Previous

Starting and Stopping Processes

Next

PowerShell for System Administration