Restart-Service

Stop and then restart one or more services.

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

Key
   -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).

   -force
       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.

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

   -whatIf
       Describe what would happen if you executed the command without
       actually executing the command.
	   
   -confirm
       Prompt for confirmation before executing the command.

   CommonParameters:
       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,
       -OutBuffer -OutVariable.

Examples

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

“I am not sure I should have dared to start; but I am sure that I should not have dared to stop” ~ Winston Churchill

Related:

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


© Copyright SS64.com 1999-2014
Some rights reserved