CmdID / PowerShell / Cmdlets / Test
Test-ComputerSecureChannel
Tests and repairs the secure channel between the local computer and its domain. PowerShell reference
From the PowerShell reference 5 parameters
What it does
Tests and repairs the secure channel between the local computer and its domain. 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.
Test-ComputerSecureChannel [-Repair] [-Server <String>] [-Credential <PSCredential>] [-WhatIf] [-Confirm] [<CommonParameters>]
Test a channel between the local computer and its domain
Test-ComputerSecureChannelIdentifyTest a channel between the local computer and a domain controller
Test-ComputerSecureChannel -Server "DCName.fabrikam.com"
TrueIdentifyReset the channel between the local computer and its domain
Test-ComputerSecureChannel -RepairIdentifyDisplay detailed information about the test
Test-ComputerSecureChannel -VerboseIdentifyTest a connection before you run a script
if (!(Test-ComputerSecureChannel)) {
Write-Host "Connection failed. Reconnect and retry."
}
else {
&(.\Get-Servers.ps1)
}IdentifyIts page in the reference: Test-ComputerSecureChannel.
Parameters
-CredentialSpecifies 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.-RepairIndicates 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.-ServerSpecifies the domain controller to run the command. If this parameter is not specified, this cmdlet selects a default domain controller for the operation.-ConfirmPrompts you for confirmation before running the cmdlet.-WhatIfShows what would happen if the cmdlet runs. The cmdlet isn't run.