Test-ComputerSecureChannel
Tests and repairs the secure channel between the local computer and its ___domain.
구문
Default (기본값)
Test-ComputerSecureChannel
[-Repair]
[-Server <String>]
[-Credential <PSCredential>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The Test-ComputerSecureChannel
cmdlet verifies that the channel between the local computer and its
___domain is working correctly by checking the status of its trust relationships. If a connection
fails, you can use the Repair parameter to try to restore it.
Test-ComputerSecureChannel
returns $true if the channel is working correctly and $false if it is
not. This result lets you use the cmdlet in conditional statements in functions and scripts. To get
more detailed test results, use the Verbose parameter.
This cmdlet works much like NetDom.exe
. Both NetDom and Test-ComputerSecureChannel
use the
NetLogon service to perform the actions.
Note
This cmdlet only works on Domain Member computers. When you run it on Domain Controllers, it
returns false positive errors. To verify and reset the secure channels for Domain Controllers,
use netdom.exe
or nltest.exe
.
예제
Example 1: Test a channel between the local computer and its ___domain
Test-ComputerSecureChannel
This command tests the channel between the local computer and the ___domain to which it is joined.
Example 2: Test a channel between the local computer and a ___domain controller
Test-ComputerSecureChannel -Server "DCName.fabrikam.com"
True
This command specifies a preferred ___domain controller for the test.
Example 3: Reset the channel between the local computer and its ___domain
Test-ComputerSecureChannel -Repair
This command resets the channel between the local computer and its ___domain.
Example 4: Display detailed information about the test
Test-ComputerSecureChannel -Verbose
VERBOSE: Performing operation "Test-ComputerSecureChannel" on Target "SERVER01".
True
VERBOSE: "The secure channel between 'SERVER01' and 'net.fabrikam.com' is alive and working correctly."
This command uses the Verbose common parameter to request detailed messages about the operation. For more information about Verbose, see about_CommonParameters.
Example 5: Test a connection before you run a script
if (!(Test-ComputerSecureChannel)) {
Write-Host "Connection failed. Reconnect and retry."
}
else {
&(.\Get-Servers.ps1)
}
This example shows how to use Test-ComputerSecureChannel
to test a connection before you run a
script that requires the connection.
The if
statement checks the value that Test-ComputerSecureChannel
returns before it runs a script.
매개 변수
-Confirm
Prompts you for confirmation before running the cmdlet.
매개 변수 속성
형식: | SwitchParameter |
Default value: | False |
와일드카드 지원: | False |
DontShow: | False |
별칭: | cf |
매개 변수 집합
(All)
Position: | Named |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
-Credential
Specifies a user account that has permission to perform this action. Type a user name, such as User01 or Domain01\User01, or enter a PSCredential object, such as one that the Get-Credential cmdlet returns. By default, the cmdlet uses the credentials of the current user.
The Credential parameter is designed for use in commands that use the Repair parameter to repair the channel between the computer and the ___domain.
매개 변수 속성
형식: | PSCredential |
Default value: | None |
와일드카드 지원: | False |
DontShow: | False |
매개 변수 집합
(All)
Position: | Named |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
-Repair
Indicates that this cmdlet removes and then rebuilds the channel established by the NetLogon service. Use this parameter to try to restore a connection that has failed the test.
To use this parameter, the current user must be a member of the Administrators group on the local computer.
매개 변수 속성
형식: | SwitchParameter |
Default value: | None |
와일드카드 지원: | False |
DontShow: | False |
매개 변수 집합
(All)
Position: | Named |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
-Server
Specifies the ___domain controller to run the command. If this parameter is not specified, this cmdlet selects a default ___domain controller for the operation.
매개 변수 속성
형식: | String |
Default value: | None |
와일드카드 지원: | False |
DontShow: | False |
매개 변수 집합
(All)
Position: | Named |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet isn't 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.
입력
None
You cannot pipe input to this cmdlet.
출력
Boolean
This cmdlet returns $true
if the connection is working correctly and $false
if it is not.
참고
- To run a
Test-ComputerSecureChannel
command on Windows Vista and later versions of the Windows operating system, open Windows PowerShell by using the Run as administrator option. Test-ComputerSecureChannel
is implemented by using the I_NetLogonControl2 function, which controls various aspects of the Netlogon service.