Powershell

How to Use the Suspend-Service (Microsoft.PowerShell.Management) Cmdlet in PowerShell?

The “Suspend-Service” cmdlet is used to suspend/pause one or more running services in PowerShell. To suspend a specified service the “Suspend-Service” cmdlet sends the message to the “Windows Service Controller” to suspend a service. When the service gets suspended, it will still run in the background but its actions will get paused. Services can be specified to the stated cmdlet by their names or display names.

In this tutorial, we will describe the usage of the “Suspend-Service” cmdlet.

How to Use the Suspend-Service (Microsoft.PowerShell.Management) Cmdlet in PowerShell?

To suspend service in PowerShell, first, use the “Suspend-Service” cmdlet. Then, specify the service by using the “-Name” or the “-DisplayName” parameter.

To understand the usage of the “Suspend-Service” cmdlet, check out the provided examples.

Example 1: Use the “Suspend-Service” Cmdlet to Suspend a Specified Service
First, use the “Suspend-Service” cmdlet. Then, write the “-DisplayName” parameter and assign it a service that needs to suspend:

Suspend-Service -DisplayName "LanMan Workstation"

Use the below-stated command to check whether the service was suspended or not:

Get-Service -DisplayName "LanMan Workstation"

Example 2: Use the “Suspend-Service” Cmdlet to Check What Will Happen If you Suspend the Specified Service
To view the consequences after suspending the service, simply use the “-WhatIf” parameter:

Suspend-Service -Name Winmgmt -WhatIf

Example 3: Use the “Suspend-Service” Cmdlet to Suspend all the Suspendable Services
Execute the below-mentioned command to suspend all the suspendable services:

Get-Service | Where-Object {$_.CanPauseAndContinue -eq "True"} | Suspend-Service -Confirm

According to the above code:

  • First, use the “Get-Service” cmdlet and pipe it to the “Where-Object” cmdlet’s specified condition.
  • Then, pipe the specified “Where-Object” condition to the “Suspend-Service” cmdlet.
  • Lastly, use the “-Confirm” parameter to ask for user confirmation at the prompt:

Type “A” when the PowerShell console asks for confirmation.

Example 4: Use the “Suspend-Service” cmdlet to Get and Suspend the Specified Service
To retrieve and suspend a particular service, first, use the “Get-Service” along with the service name and then pipe it to the “Suspend-Service” cmdlet:

Get-Service -Name stisvc | Suspend-Service

Run the given command to verify whether the service was suspended or not:

Get-Service -Name stisvc

That’s it! We have compiled the usage of the “Suspend-Service” cmdlet.

Conclusion

PowerShell’s “Suspend-Service” cmdlet suspends/pauses running services. A service that needs to be suspended is specified to the “Suspend-Service” cmdlet using its name or display name. This tutorial demonstrated the practical usage of PowerShell’s “Suspend-Service” cmdlet with the help of various examples.

About the author

Muhammad Farhan

I am a Computer Science graduate and now a technical writer who loves to provide the easiest solutions to the most difficult problems related to Windows, Linux, and Web designing. My love for Computer Science emerges every day because of its ease in our everyday life.