SUSPEND-SERVICE | TAKING ON POWERSHELL ONE CMDLET AT A TIME | WEEKLY BLOG

SUSPEND-SERVICE | TAKING ON POWERSHELL ONE CMDLET AT A TIME | WEEKLY BLOG

This is a part of an on-going blog series written by ME ... Adam Gordon. Each week, I will walk you through a PowerShell command, showing you when and how to use each one. This week, Adam covers Suspend-Service.

When to use Suspend-Service?

The Suspend-Service cmdlet sends a suspend message to the Windows Service Controller for each of the specified services. While suspended, the service is still running, but its action is stopped until resumed, such as by using the Resume-Service cmdlet.

You can specify the services by their service names or display names, or you can use the InputObject parameter to pass a service object that represents the services that you want to suspend.

What version of PowerShell am I using?

Get the PowerShell Version from your machine:

$PSVersionTable

This command shows you the PowerShell version information on your machine.

No alt text provided for this image

How to use Suspend-Service?

Suspend a service:

Suspend-Service -DisplayName "Waves Audio Services"

This command suspends the Waves Audio Services service (WavesSysSvc64) service on the local computer.

No alt text provided for this image

Get and suspend a service:

This command uses the Get-Service cmdlet to get an object that represents the Waves Audio Services service on the computer.

The pipeline operator (|) passes the result to Suspend-Service, which suspends the service.

Get-Service "Waves Audio Services" | Suspend-Service

No alt text provided for this image

Suspend all services that can be suspended:

This command suspends all of the services on the computer that can be suspended. It uses Get-Service to get objects that represent the services on the computer.

The pipeline operator passes the results to the Where-Object cmdlet, which selects only the services that have a value of $True for the CanPauseAndContinue property.

Another pipeline operator passes the results to Suspend-Service. The -Confirm parameter prompts you for confirmation before suspending each of the services.

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

No alt text provided for this image


Ryan R.

Lead Network Security Engineer at SpaceX

3 年

Tuned in

回复

要查看或添加评论,请登录

Adam Gordon的更多文章

社区洞察

其他会员也浏览了