A user tries to sign in to their work PC and Windows shows:
The trust relationship between this workstation and the primary domain failed.
Nobody can log in with a domain account. This is a common Active Directory problem, and the fix usually takes a few minutes. You often don’t even need to remove the PC from the domain.
Why it happens
Every domain-joined computer has its own account in Active Directory, with a password that Windows changes automatically (by default every 30 days). The computer stores its current password locally, and the domain controller stores a copy.
If the two copies no longer match, the domain controller refuses to trust the computer. Common causes:
- Restoring a snapshot or old backup of the PC or virtual machine, which brings back an old computer password
- Re-imaging or cloning a machine without running Sysprep
- The computer account was reset or deleted in Active Directory
- Two computers with the same name joined to the domain
- A PC that was offline for a long time while its account was cleaned up
- Restoring a domain controller from an old backup
Before you start
You’ll need:
- A local administrator account on the PC (for example, the one managed by Windows LAPS), or a cached domain admin login
- Domain credentials with permission to reset computer accounts
- A network connection to a domain controller
If the PC is a laptop, connect it to the office network or the VPN first.
Fix 1: Reset the machine password with PowerShell (no rejoin)
- Sign in with a local administrator account. Use
.\AdministratororCOMPUTERNAME\localadminas the username. - Open PowerShell as administrator.
- Test the secure channel:
Test-ComputerSecureChannel -Verbose
If it returns False, the trust is broken.
- Repair it:
Test-ComputerSecureChannel -Repair -Credential (Get-Credential)
Enter a domain account with permission to reset computer accounts, for example CORP\itadmin.
- Run
Test-ComputerSecureChannelagain. It should now returnTrue. - Restart the PC and sign in with the user’s domain account.
An alternative command that does the same thing is:
Reset-ComputerMachinePassword -Server DC01 -Credential (Get-Credential)
Fix 2: Use netdom
On older systems, or if PowerShell isn’t convenient, netdom (part of the Remote Server Administration Tools) can reset the password from an elevated Command Prompt:
netdom resetpwd /server:DC01 /userd:CORP\itadmin /passwordd:*
Restart the PC afterwards.
Fix 3: Rejoin the domain (last resort)
If the repair commands fail, for example because the computer account was deleted, rejoin the domain:
- Sign in with a local administrator account.
- Open Settings > System > About > Domain or workgroup (or run
sysdm.cpl). - Click Change, select Workgroup, enter any name (for example
TEMP), and restart. - Sign in with the local admin account again, change back to Domain, enter your domain name and credentials, and restart.
User profiles normally stay on the PC. The user’s profile should reconnect when they sign in with the same domain account. To be safe, back up important files first.
In PowerShell, you can rejoin in one step after removing the PC:
Add-Computer -DomainName corp.example.com -Credential (Get-Credential) -Restart
No local admin password?
If nobody knows a local admin password and the PC can’t log in to the domain:
- Disconnect the network cable or Wi-Fi and try signing in with the user’s domain account. Windows may use cached credentials, which lets you sign in and run the fixes as long as that user is a local admin.
- Use Windows LAPS to look up the local admin password in Active Directory or Microsoft Entra ID. This is exactly the situation LAPS is designed for. See our Windows 11 hardening checklist.
- As a last resort, reset the local admin password with your organisation’s approved recovery tools.
How to prevent it
- Don’t restore old VM snapshots of domain-joined machines without planning for this. If you have to, reset the machine password afterwards.
- Use Sysprep when cloning or imaging Windows.
- Avoid duplicate computer names.
- Don’t delete computer accounts for laptops that may still be in use. Disable stale accounts first and delete them later.
- Make sure laptops connect to the domain (directly or through the VPN) at least every few weeks.
- Deploy Windows LAPS so you always have a working local admin password.
Quick summary
| Situation | Fix |
|---|---|
| Normal case, local admin available | Test-ComputerSecureChannel -Repair then restart |
| Older Windows or no PowerShell | netdom resetpwd then restart |
| Computer account deleted | Rejoin the domain |
| No local admin password | Use LAPS or cached credentials offline |
This is also a Fix It Friday topic on our Instagram. For more domain troubleshooting, see our guide to Group Policy not applying.

