Restart-Service
Stops and then starts one or more services.
구문
InputObject (기본값)
Restart-Service
[-InputObject] <ServiceController[]>
[-Force]
[-PassThru]
[-Include <String[]>]
[-Exclude <String[]>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Default
Restart-Service
[-Name] <String[]>
[-Force]
[-PassThru]
[-Include <String[]>]
[-Exclude <String[]>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
DisplayName
Restart-Service
-DisplayName <String[]>
[-Force]
[-PassThru]
[-Include <String[]>]
[-Exclude <String[]>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
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
you can use the InputObject parameter to pass an object that represents each service that you
want to restart.
예제
Example 1: Restart a service on the local computer
PS C:\> Restart-Service -Name winmgmt
This command restarts the Windows Management Instrumentation service (WinMgmt) on the local computer.
Example 2: Exclude a service
PS C:\> Restart-Service -DisplayName "net*" -Exclude "net logon"
This command restarts the services that have a display name that starts with Net, except for the Net Logon service.
Example 3: Start all stopped network services
PS C:\> Get-Service -Name "net*" | Where-Object {$_.Status -eq "Stopped"} | Restart-Service
This command starts all of the stopped network services on the computer.
This command uses the Get-Service
cmdlet to get objects that represent the services whose service
name starts with net. The pipeline operator (|
) sends the services object to the Where-Object
cmdlet, which selects only the services that have a status of stopped. Another pipeline operator
sends the selected services to Restart-Service
.
In practice, you would use the WhatIf parameter to determine the effect of the command before you run it.
매개 변수
-Confirm
Prompts you for confirmation before running the cmdlet.
매개 변수 속성
형식: | SwitchParameter |
Default value: | False |
와일드카드 지원: | False |
DontShow: | False |
별칭: | cf |
매개 변수 집합
(All)
Position: | Named |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
-DisplayName
Specifies the display names of the services to restarted. Wildcard characters are permitted.
매개 변수 속성
형식: | String[] |
Default value: | None |
와일드카드 지원: | True |
DontShow: | False |
매개 변수 집합
DisplayName
Position: | Named |
필수: | True |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
-Exclude
Specifies services that this cmdlet omits. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as s*. Wildcard characters are permitted.
매개 변수 속성
형식: | String[] |
Default value: | None |
와일드카드 지원: | True |
DontShow: | False |
매개 변수 집합
(All)
Position: | Named |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
-Force
Forces the command to run without asking for user confirmation.
매개 변수 속성
형식: | SwitchParameter |
Default value: | None |
와일드카드 지원: | False |
DontShow: | False |
매개 변수 집합
(All)
Position: | Named |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
-Include
Specifies services that this cmdlet restarts. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as s*. Wildcard characters are permitted.
매개 변수 속성
형식: | String[] |
Default value: | None |
와일드카드 지원: | True |
DontShow: | False |
매개 변수 집합
(All)
Position: | Named |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
-InputObject
Specifies ServiceController objects that represent the services to restart. Enter a variable that contains the objects, or type a command or expression that gets the objects.
매개 변수 속성
형식: | |
Default value: | None |
와일드카드 지원: | False |
DontShow: | False |
매개 변수 집합
InputObject
Position: | 0 |
필수: | True |
파이프라인의 값: | True |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
-Name
Specifies the service names of the services to restart.
매개 변수 속성
형식: | String[] |
Default value: | None |
와일드카드 지원: | True |
DontShow: | False |
별칭: | ServiceName |
매개 변수 집합
Default
Position: | 0 |
필수: | True |
파이프라인의 값: | True |
속성 이름별 파이프라인의 값: | True |
나머지 인수의 값: | False |
-PassThru
Returns an object that represents the service. By default, this cmdlet does not generate any output.
매개 변수 속성
형식: | SwitchParameter |
Default value: | None |
와일드카드 지원: | False |
DontShow: | False |
매개 변수 집합
(All)
Position: | Named |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
매개 변수 속성
형식: | SwitchParameter |
Default value: | False |
와일드카드 지원: | False |
DontShow: | False |
별칭: | wi |
매개 변수 집합
(All)
Position: | Named |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
입력
ServiceController
You can pipe a service object to this cmdlet.
String
You can pipe a string that contains a service name to this cmdlet.
출력
None
By default, this cmdlet returns no output.
ServiceController
When you use the PassThru parameter, this cmdlet returns a ServiceController object representing the restarted service.
참고
Restart-Service
can control services only when the current user has permission to do this. If a command does not work correctly, you might not have the required permissions.- To find the service names and display names of the services on your system, type
Get-Service
". The service names appear in the Name column, and the display names appear in the DisplayName column.