- August 18, 2018
- Posted by: Surender Kumar
- Categories: PowerShell, Tips & Tricks
The trust relationship between this workstation and the primary domain failed
If you ever got the message “The trust relationship between this workstation and the primary domain failed“, you can probably can solve this my removing the computer from domain and re-joining it again. But I will show you a really easy and neat way of solving this error by using Windows PowerShell.

Because of this error, you cannot login onto domain using any user account but you can always login via local administrator account. If you login with a local admin user and run the following PowerShell command:
Test-ComputerSecureChannel -Verbose
The command returns False and you’ll see The secure channel between the local computer and the domain techtuts.local
is broken error in verbose output (see the screenshot for reference).

To fix this error, follow these steps:
- Login to the server or computer via local administrator account.
- Open elevated Windows PowerShell console.
- Type the following command and hit Enter:
Test-ComputerSecureChannel -Repair -Credential yourDomain\admin
This command will attempt to repair the broken trust relationship. If successful, it will return True in output. See the following screenshot for reference:
The secure channel between the local computer and the domain is in good condition - In case you see an error that says “Cannot find the computer account for the local computer in the domain”, the computer account might have been accidentally deleted. In that case, you need to create the computer account in the right OU and then try to run Test-ComputerSecureChannel -Repair command again. If this command doesn’t resolve your problem, run the following PowerShell command:
Reset-ComputerMachinePassword -Server DC1 -Credential yourDomain\Admin
Just type the password of domain admin user and hit Enter. Of course, replace DC1 with your domain controller and yourDomain\Admin with your domain name and domain admin account.
- Restart the computer and now you will be able to login onto domain.