Over the last few articles we’ve been exploring different ways to gather relevant service information from local and remote computers using PowerShell. In Part 3 of this series I will explain how to start, stop and restart Services with PowerShell.
PS C:\> get-service bits

Status  Name     DisplayName
------  ----     -----------
Running bits     Background Intelligent Transfer Ser...

Since the command to get a service is called Get-Service, you can probably make a pretty good guess about the names of the other commands. Or, ask PowerShell to tell you all of the commands related to services.

get-command -noun service

get-command -noun service

Let’s look at these commands in a little more detail.


To stop a service, all we need to do is specify the service name.

PS C:\> stop-service wuauserv

But you’ll get nothing written to the pipeline. Some cmdlets, like Stop-Service, are designed so that by default they do not write an object to the pipeline. But you can force it by using the –Passthru parameter.

PS C:\> stop-service bits -PassThru

Status  Name        DisplayName
------  ----        -----------
Stopped bits        Background Intelligent Transfer Ser...

If the service isn’t running the cmdlet won’t do anything, nor will you get an error. Sometimes the best thing is to pipe a service object to Stop-Service.

PS C:\> get-service browser | stop-service -WhatIf

What if: Performing operation "Stop-Service" on Target "Computer Browser (browser)".

In this example I added the –WhatIf parameter which will indicate what the cmdlet would do if you allowed it. This is a nice sanity check. When I’m assured that I have the correct service, I can press the up arrow to get the previous command, delete –Whatif and stop the service.

PS C:\> get-service browser | stop-service

As I mentioned, if the service is already stopped, the cmdlet won’t really do anything. And even though there is no harm in running Stop-Service, if you prefer a more controlled approach you can use logic like this:

PS C:\> get-service bits | where {$_.status -eq 'running'} | stop-service -pass

Status Name DisplayName
------ ---- -----------
Stopped bits Background Intelligent Transfer Ser...

If the service is running, then the service object is passed on in the pipeline and sent to Stop-Service. This is also a handy technique for stopping multiple services.

PS C:\> get-service bits,wsearch,winrm,spooler | where {$_.status -eq 'running'} | stop-service -whatif

What if: Performing operation "Stop-Service" on Target "Print Spooler (spooler)".
What if: Performing operation "Stop-Service" on Target "Windows Remote Management (WS-Management) (winrm)".
What if: Performing operation "Stop-Service" on Target "Windows Search (wsearch)".

Some services may refuse to stop if there are dependent services as you can see in the screenshot.



In these situations, the solution is to use the –Force parameter. This should work most of the time, but isn’t foolproof. You may have to try the command more than once. Be aware that this will also stop dependent services.

PS C:\> stop-service lanmanserver -force –PassThru

Status   Name             DisplayName
------   ----             -----------
Stopped  Browser          Computer Browser
Stopped  lanmanserver     Server


Starting a service works essentially the same way. It supports –Whatif and you’ll need to use –Passthru to see any objects.

PS C:\> start-service wuauserv -PassThru

Status    Name             DisplayName
------    ----             -----------
Running   wuauserv         Windows Update

Again, if the service is already running the cmdlet has no impact. But you might try to start a service and get an error like in the screenshot below.



This is almost always due to a disabled service. In the next article I’ll explain how to configure service settings.

If you want to start a service and all of its dependencies, try a one line expression like this:

PS C:\> get-service lanmanserver | Foreach { start-service $_.name -passthru; start
-service $_.DependentServices -passthru}

Status   Name            DisplayName
------   ----            -----------
Running lanmanserver     Server
Running Browser          Computer Browser

We have to explicitly get all the dependent services because Start-Service won’t automatically start dependencies.


Restarting a service also works the same way. Use –Passthru if you want to verify the service is running.

PS C:\> restart-service spooler -PassThru

Status   Name          DisplayName
------   ----          -----------
Running  spooler       Print Spooler

Because this is stopping the service, you may need to use –Force.

Suspend and Resume

Some services can be suspended and resumed, in which case we can do so from PowerShell. But if the service doesn’t meet the requirements you’ll get an error like in the screenshot.



How can you tell? Look at the service object.

PS C:\> get-service bits | select *

Name                : bits
RequiredServices    : {RpcSs, EventSystem}
CanPauseAndContinue : False
CanShutdown         : False
CanStop             : True
DisplayName         : Background Intelligent Transfer Service
DependentServices   : {}
MachineName         : .
ServiceName         : bits
ServicesDependedOn  : {RpcSs, EventSystem}
ServiceHandle       : SafeServiceHandle
Status              : Running
ServiceType         : Win32ShareProcess
Site                :
Container           :

If the CanPauseAndContinue property is set to True then you should be able to suspend and resume.

PS C:\> get-service | where {$_.CanPauseandContinue}
Status   Name                       DisplayName
------   ----                       -----------
Running  LanmanServer               Server
Running  LanmanWorkstation          Workstation
Running  MSSQLSERVER                SQL Server (MSSQLSERVER)
Running  O2FLASH                    O2FLASH
Running  stisvc                     Windows Image Acquisition (WIA)
Running  Winmgmt                    Windows Management Instrumentation

Not too many services meet this requirement.

PS C:\> suspend-service o2flash -PassThru

Status   Name                      DisplayName
------   ----                      -----------
Paused   O2FLASH                   o2flash

Then when I’m ready to resume:

PS C:\> resume-service o2flash -PassThru

Status   Name                     DisplayName
------   ----                     -----------
Running  O2FLASH                  o2flash

Both cmdlets also support –Whatif.

Remote Services

You may have noticed that all of my examples were done on the local machine. That wasn’t an accident. Unfortunately, even in PowerShell v3, none of these cmdlets have a parameter that allow you to manage a service on a remote computer. Yes, Get-Service supports –Computername but that’s it. You can see the service but you can’t do anything about it. Well, actually you can if the remote computer is running PowerShell v2 or later with remoting enabled. You can run all of the commands I’ve demonstrated in this article using Invoke-Command against a remote computer or PSSession. On the other hand, it also makes it very easy to manage the same service on multiple servers.

PS C:\> Invoke-Command {restart-service dns –passthru} –comp chi-dc03,chi-dc02,chi-dc01



There are additional ways to manage services on remote computers which I’ll cover in an upcoming article.


All of these cmdlets can be used in a pipeline expression and often that is the best option. Use Get-Service to retrieve service objects and then pipe them to the appropriate cmdlet. Be sure to look at complete help and examples for all of the cmdlets I’ve covered in this article. Next time we’ll look at configuring services.

  1. Subair Ahmed Makhdoom 9 years ago

    Hi Jeff,

    Thank a lot for sharing your knowledge,
    i tried below command to restart vss service on remote computer “oss01” its working fine.

    Get-Service vss -ComputerName oss01 | Restart-Service -PassThru



  2. Fazil 8 years ago

    Hi, I like reading your blog. Hope you would able to help me in resolving my concern.

    I Am a Websphere Application Server – Admin. I have physical machine windows2008, in which I have installed my software. I have created 4 JVM’s of server has my enterprise application running.
    Now I need to have my 4 JVM to restart automatically.

    please help!

  3. Author
    Jeff Hicks 8 years ago

    I have no idea if there are any Websphere cmdlets. You’ll have to track that down and then read the help on how to use them. This isn’t something you can just “do” in PowerShell.

  4. dungphi 7 years ago

    hi, when i start windows, my windows is auto open powershell. but now, i when i start windows, i dont want my windows is auto open powershell. please help me?

  5. robin 7 years ago

    Thanks Jeff , nice tutorial .

  6. Raymar 7 years ago

    Can we restrict a list of service not be restarted in powershell? Like if we do a restart-service. The restricted service will not be restarted?

    • Paul M Edwards 6 years ago

      The built-in help documentation for the Restart-Service command indicates you can exclude services using the -Exclude parameter…

  7. DM 7 years ago


    Is there a method for a end user to be able to restart or even stop and restart a license service on a Service.

    I have compiled the below as an example:

    Get-Service -ComputerName SERVER01 -Name license manager | Stop-Service -Force

    Get-Service -ComputerName SERVER01 -Name license manager | Start-Service -Force

    Thank you


  8. Charlie 5 years ago

    Hi, i am trying to find a way to remotely disable application services on a group of devices.  I want to use a .txt file to list out the devices and then run a powershell script against that list to disable up to three services.  Everything i’ve tried seems to fail.  Any help is greatly appreciated.

  9. Joe 5 years ago

    Hi, what firewall rule needs to be implemented?

  10. Adrian A Nielsen 4 years ago

    Why would one prefer to suspend-service as opposed to stop-service? 

    • Suspend-Service updates the process state to Pause. In the Paused state process is not terminated, it maintains its cache( e.g. DNS cache). And when resumed service can continue from where it left off. When we use stop-service, the process is terminated and the service state is lost. When we restart a service it creates a new instance of the process and it re-initializes the cache/configuration with new values.


Leave a reply

Your email address will not be published. Required fields are marked *


© 4sysops 2006 - 2023


Please ask IT administration questions in the forums. Any other messages are welcome.


Log in with your credentials


Forgot your details?

Create Account