How to fix “The trust relationship between this workstation and the primary domain failed” with PowerShell

When you attempt to login to a Windows computer and get the message “The trust relationship between this workstation and the primary domain failed”, it usually means the computer’s machine account password does not match anymore with the one in the Active Directory database.

Typically to resolve the issue, you would login to the computer with a local administrator account, put the computer in a workgroup, then reboot, again join the computer to the domain, and reboot again.

However, a much quicker way is to run the below PowerShell oneliner which requires no reboot.

Obviously, the domain user you specify on the Credential parameter should be a user which has the proper privileges to manage computer accounts in Active Directory

Leave a Reply

Your email address will not be published. Required fields are marked *