PowerShell Logo Small

Restart-Service



This is the built-in help made by Microsoft for the command 'Restart-Service', in PowerShell version 2 - as retrieved from Windows version 'Microsoft® Windows Vista™ Ultimate ' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Stops and then starts one or more services.

SYNTAX


Restart-Service [-Name] <string[]> [-Exclude <string[]>] [-Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]
Restart-Service -DisplayName <string[]> [-Exclude <string[]>] [-Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>
]
Restart-Service [-InputObject <ServiceController[]>] [-Exclude <string[]>] [-Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [<Comm
onParameters>]



Search powershellhelp.space

DESCRIPTION


The Restart-Service cmdlet sends a stop message and then a start message to the Windows Service Controller for a specified service. If a service
was already stopped, it is started without notifying you of an error. You can specify the services by their service names or display names, or yo
u can use the InputObject parameter to pass an object that represents each service that you want to restart.



<

RELATED LINKS

Online version: http://go.microsoft.com/fwlink/?LinkID=113385
Start-Service
Stop-Service
Suspend-Service
Resume-Service
New-Service
Get-Service
Set-Service

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

C:\PS>restart-service wmi



Description
-----------
This command restarts the Windows Management Instrumentation (WMI) service on the local computer.








-------------------------- EXAMPLE 2 --------------------------

C:\PS>restart-service -displayname net* -exclude "net logon"



Description
-----------
This command restarts the services that have a display name that begins with "Net", except for the "Net Logon" service.








-------------------------- EXAMPLE 3 --------------------------

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



Description
-----------
This command starts all of the stopped network services on the computer.

It uses the Get-Service cmdlet to get objects representing the services whose service name begins with "net". (The optional Name parameter name i
s omitted.) The pipeline operator (|) sends the services object to the Where-Object cmdlet, which selects only the services with a status of "sto
pped." Another pipeline operator sends the selected services to Restart-Service. In practice, you would use the WhatIf parameter to see the effec
t of the command before using it.