Stop and then restart one or more services.

      Restart-Service { [-name] string[]
                      | [-displayName] string[]
                      | [-inputObject ServiceController[]] }
                           [-force] [-include string[]] [-exclude string[]]
                              [-passthru] [-whatIf]
                                 [-confirm] [CommonParameters]

   -name string
       The service names to be restarted.

   -displayName string
       The display names to be restarted, wildcards are permitted.

   -inputObject ServiceController
       Restart the services represented by ServiceController.
       Enter a command, expression or variable containing the object(s).

       Override restrictions that prevent the command from succeeding, apart
       from security settings. e.g. -Force will stop and restart a
       service that has dependent services.

   -include string
       Restart only the specified services. Qualifies the -Name parameter.
       Wildcards , such as "s*" are permitted.

   -exclude string
       Omit the specified services e.g. "*SS64*"
       Qualifies the -Name parameter, Wildcards are permitted.

        Pass the object created by Restart-Service along the pipeline. 

       Describe what would happen if you executed the command without
       actually executing the command.

       Prompt for confirmation before executing the command.


Restart the spooler (printing) service:

PS C:\> restart-service spooler -force

Find all the network services on the computer (starting with "net...") and restart any that are stopped:

PS C:\> get-service net* | where {$_.Status -eq "Stopped"} | restart-service

“DALEK: Halt at once. Halt or you will be exterminated. It is the Doctor.
  The Doctor must be destroyed. Exterminate. Exterminate. Exterminate!” ~ Dr Who, 1983

Related PowerShell Cmdlets

Get-Service - Get a list of services.
New-Service - Create a new service.
Resume-Service - Resume a suspended service.
- Make and set changes to the properties of a service.
- Start a stopped service.
- Stop a running service.
- Suspend a running service.
Windows cmd commands: NET START / SC - Service Control.

Copyright © 1999-2024
Some rights reserved