Test and repair the secure channel between the local computer and its domain.

      Test-ComputerSecureChannel [-Repair] [-Server string]
         [-Confirm] [-WhatIf] [CommonParameters]

       Remove and then rebuild the secure channel established by the
       NetLogon service. Use this parameter to try to restore a connection
       that has failed the test (returned "False".)

To use this parameter, the current user must be a member of the Administrators group on the local computer.

-Server string Use the specified domain controller to run the command. If this parameter is omitted, Test-ComputerSecureChannel selects a default domain controller for the operation. -Confirm Prompt for confirmation before executing the command. -WhatIf Describe what would happen if you executed the command without actually executing it. CommonParameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable, -OutBuffer -OutVariable.

Test-ComputerSecureChannel verifies that the secure channel between the local computer and its domain is working correctly by checking the status of its trust relationships. If a connection fails, use the -Repair parameter to try to restore it.

Test-ComputerSecureChannel returns "True" if the secure 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.


Test the secure channel between the local computer and the domain to which it is joined:

PS C:> test-computersecurechannel

Use Test-ComputerSecureChannel to test a connection before running a script that requires the connection:

PS C:> if (!(test-computersecurechannel))
     {write-host "Connection failed. Reconnect and retry."}
else { &(.\collectserverdata.ps1) }

Use Invoke-Command to run a Reset-ComputerMachinePassword command on the Server64 remote computer.

PS C:> invoke-command -computername Server64 -scriptblock {reset-computermachinepassword}

“Life is thickly sown with thorns, and I know no other remedy than to pass quickly through them. The longer we dwell on our misfortunes, the greater is their power to harm us” ~ Voltaire


Restart-Computer - Restart the operating system on a computer
Test-Connection - Ping one or more computers

Copyright © SS64.com 1999-2017
Some rights reserved