Active Directory
Fix "The trust relationship between this workstation and the primary domain failed"
Reset the computer's secure channel with the domain from PowerShell instead of rejoining the domain.
This error means the computer's machine account password no longer matches the one in Active Directory. Common causes: the machine was restored from an old snapshot or image, it was offline far longer than the password age, or another computer was joined with the same name.
Check the secure channel
Sign in with a local administrator account (or cached domain credentials if they still work), then in an elevated Windows PowerShell 5.1 window:
1Test-ComputerSecureChannel -VerboseFalse confirms the broken channel. You can also run nltest /sc_verify:contoso.com.
Repair it
1Test-ComputerSecureChannel -Repair -Credential CONTOSO\admin-jdoeOr reset the password against a specific domain controller:
1Reset-ComputerMachinePassword -Server DC01 -Credential CONTOSO\admin-jdoeThe account needs permission to reset the computer object's password (for example a member of a group delegated on that OU). Restart afterwards and sign in with a domain account.
When you must rejoin
If the computer object was deleted from AD, there's nothing to reset: remove the computer from the domain (join a workgroup), restart, and join again.
References
- Test-ComputerSecureChannel — Microsoft Learn
- Reset-ComputerMachinePassword — Microsoft Learn