How to stop a windows service using PowerShell?

PowerShellMicrosoft TechnologiesSoftware & Coding

To stop specific service using PowerShell, you need to use Stop-Service command.

Syntax

Stop-Service -Name ServiceName
Stop-Service -DisplayName ServiceDisplayName

Example

Stop-Service -Name Spooler

To check if service is stopped, type Get-Service -Name Spooler.

Output

Status   Name           DisplayName
------   ----           -----------
Stopped  Spooler           Print Spooler

You can also use -Verbose parameter to check the command processes.

PS C:\Windows\system32> Stop-Service -Name spooler -Verbose
VERBOSE: Performing the operation "Stop-Service" on target "Print Spooler (spooler)".

You can also perform the stop the service using,

Get-Service -Name Spooler | Stop-Service -Verbose

You can also use the wildcard character (*) to recognize the service and stop it.

For Example,

Stop-Service -Name Spoo* -Verbose

Here, service name starts with “spoo” will be stopped, if there are multiple services starting with spoo, all will be stopped.

raja
Published on 22-Jan-2020 08:07:43
Advertisements