SUSPEND-SERVICE | TAKING ON POWERSHELL ONE CMDLET AT A TIME | WEEKLY BLOG
Adam Gordon
An Advanced Security Practitioner, Author, Global Speaker, Educator & Executive with decades of Cybersecurity/Information Assurance/GRC/Information Technology/Regulatory & Cloud experience.
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.
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.
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
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
Lead Network Security Engineer at SpaceX
3 年Tuned in