Repairing the domain trust relationship between workstation and Active Directory

To repair the domain trust relationship, sign in to the workstation with a local administrator account, open Windows PowerShell as administrator and run Test-ComputerSecureChannel -Repair -Credential CONTOSO\Admin with a domain account, then restart.

This guide covers what the error means, the machine account password behind it, every official repair route from PowerShell, nltest and netdom to a full domain rejoin, and how to stop the trust from breaking again.

Repairing the domain trust relationship between workstation and Active Directory
Windows shows this message at sign-in when the computer password no longer matches the copy held in Active Directory. (Image: Microsoft)

Repair broken trust between computer and domain with PowerShell

Microsoft's documented fix rebuilds the secure channel in place. The computer keeps its domain membership, its computer object and its group memberships, so no rejoin is needed.

  1. Sign in to the workstation with a local administrator account, such as .\Administrator or another local account in the Administrators group.
  2. Select Start, type PowerShell, right-click Windows PowerShell and select Run as administrator.
  3. Run Test-ComputerSecureChannel -Verbose to see the current state. False means the trust is broken.
  4. Run Test-ComputerSecureChannel -Repair -Credential CONTOSO\Admin, replacing the domain and user with an account that may reset computer passwords in your domain.
  5. Type that account's password in the credential prompt and select OK.
  6. Run Test-ComputerSecureChannel again and wait for True.
  7. Restart the computer and sign in with your domain account.

The -Repair switch removes and then rebuilds the channel that the NetLogon service uses. The account running PowerShell must be a member of the local Administrators group.

To pick a specific domain controller, add -Server "DC01.contoso.com" to both commands. This helps when one DC holds the newest copy of the computer password.

The trust relationship between this workstation and the primary domain failed

Windows shows this message at the sign-in screen when the computer can no longer authenticate itself to a domain controller. Each domain member holds a secret password for its computer account, and Active Directory holds a copy. When the two copies stop matching, the secure channel fails and domain sign-ins are refused.

Local accounts still sign in, and a domain user who signed in before can often use cached credentials.

What you see Where What it means
"The trust relationship between this workstation and the primary domain failed." Sign-in screen or Remote Desktop Domain credentials are refused because the secure channel is broken
Event ID 3210, source NETLOGON Event Viewer > System log The computer could not authenticate with a named domain controller
Trusted DC Connection Status Status = 5 0x5 ERROR_ACCESS_DENIED nltest /sc_query:contoso.com output The domain controller rejected the computer password
False Test-ComputerSecureChannel output The channel between this computer and its domain does not work
Computer password older than the AD copy Workstation The machine was rolled back by a snapshot, backup or restore point
AD copy older than the computer password Domain controllers Replication failed, a DC was restored from backup, or the computer object was restored

Event 3210 also names a second possible cause: another computer on the network using the same name. Check for a duplicate name before you repair a machine that keeps failing.

Trust relationship failed Event ID 3210 NETLOGON error in Event Viewer System log
Event 3210 names the domain controller the computer could not authenticate with, a clue to where the password mismatch sits. (Image: Microsoft)

Machine (computer) account password in Active Directory

The computer account password is separate from any user password. The workstation changes it on its own schedule and stores it as an LSA secret, while Active Directory records the change in the computer object's pwdLastSet attribute. The domain member starts each change, not the domain controller.

Machine account settings are not the same as the domain password policy for users, even though both live under Security Settings in Group Policy.

Setting or value Default Where to find it
Domain member: Maximum machine account password age 30 days (values 1 to 999) Computer Configuration > Windows Settings > Security Settings > Local Policies > Security Options
Domain member: Disable machine account password changes Disabled Same Security Options node
pwdLastSet (PasswordLastSet) Updated at each successful change Computer object in Active Directory; Get-ADComputer 'PC01' -Properties PasswordLastSet
Event ID 5823, source NETLOGON Logged on each successful change Event Viewer > System log on the workstation
cupdtime Last change known to the workstation HKLM\SECURITY\Policy\Secrets\$MACHINE.ACC, readable only by SYSTEM by default

Comparing pwdLastSet in Active Directory with the workstation's last 5823 event tells you which side holds the newer password, and that decides where the real fix belongs.

Machine account password change logged as NETLOGON Event ID 5823 on the workstation
Each successful computer password change logs Event 5823 on the workstation; compare its date with pwdLastSet in Active Directory. (Image: Microsoft)

How to log in when the trust relationship between workstation and domain failed

Every repair runs on the broken workstation, so you need a way in first. Microsoft confirms that local accounts and cached domain credentials still work.

What you have How to sign in Then
A local administrator password Sign in at the Windows sign-in screen as .\Administrator or PCNAME\localadmin Run the PowerShell repair with -Credential for a domain account
A domain account that signed in to this PC before Sign in with that account's cached credentials Make sure the network can reach a domain controller before you run the repair
Remote access from another domain computer Use Invoke-Command with admin credentials Run Reset-ComputerMachinePassword inside the script block

Test-ComputerSecureChannel vs nltest vs rejoin domain

Your situation Use this Why
Windows 10 or 11 workstation or member server, PowerShell available Test-ComputerSecureChannel -Repair -Credential Rebuilds the channel in place and returns True or False
Command Prompt only, or a script that must use cmd nltest /sc_reset:contoso.com Removes and rebuilds the same NetLogon channel
Repair returns True but sign-in still fails, or you want a fresh password Reset-ComputerMachinePassword Sets a new computer account password on a domain controller
The broken machine is a domain controller netdom resetpwd Test-ComputerSecureChannel gives false results on DCs
Every repair fails, or the computer object was deleted Remove the computer from the domain and join it again Creates a new trust from scratch

Fix trust relationship with nltest /sc_reset

Microsoft lists nltest next to the PowerShell cmdlet as the fix for both password-mismatch scenarios. Run it from an elevated Command Prompt while signed in with an account that has domain admin rights, or as a local admin with a domain admin's credentials available.

nltest /sc_reset:contoso.com

Removes, and then rebuilds, the secure channel that the NetLogon service established with a domain controller in contoso.com. Replace contoso.com with your domain name. Run nltest /sc_query:contoso.com afterwards to read the new state.

You should see: nltest /sc_query reports Trusted DC Connection Status Status = 0 0x0 NERR_Success and names the trusted domain controller. Restart the computer before you sign in with a domain account.

Reset-ComputerMachinePassword to fix the trust relationship

When the channel repair does not hold, reset the computer account password itself. The cmdlet changes the password the computer uses to authenticate to domain controllers and writes the new value to Active Directory.

  1. Sign in locally and open Windows PowerShell with Run as administrator.
  2. Run Reset-ComputerMachinePassword -Server "DC01" -Credential CONTOSO\Admin, using a DC name and an account that may reset computer passwords.
  3. Enter the password when prompted. The cmdlet prints nothing when it succeeds.
  4. Run Test-ComputerSecureChannel -Verbose and look for True.
  5. Restart the computer and sign in with a domain account.

To fix a machine you can still reach over the network, run it remotely: $cred = Get-Credential and then Invoke-Command -ComputerName "PC01" -ScriptBlock { Reset-ComputerMachinePassword -Credential $Using:cred }.

Reset domain controller machine password with netdom resetpwd

A domain controller needs a different tool. Microsoft notes that Test-ComputerSecureChannel returns false positive errors on DCs, and netdom resetpwd works only on the domain controller whose own password you reset. It does not reset member servers or remote machines, so do not use it on a workstation.

netdom resetpwd /server:DC02 /userd:CONTOSO\Admin /passwordd:*

Run it from an elevated Command Prompt on the affected DC. /server names a healthy domain controller to set the password against, /userd is the admin account and /passwordd:* prompts for its password instead of showing it. Netdom ships with the AD DS role and the RSAT AD DS tools.

You should see: Restart the DC after the reset, then run nltest /sc_query:contoso.com and check replication before you return it to service.

Fix trust relationship by rejoining the domain

Rejoining is Microsoft's last option, and a valid one. It removes the computer from the domain, then joins it again so a new computer account password is created. You need local admin rights on the machine and a domain account allowed to join computers.

  1. Sign in with a local administrator account and open Windows PowerShell as administrator.
  2. Run Remove-Computer -UnjoinDomainCredential CONTOSO\Admin -WorkgroupName "TEMP" -PassThru -Verbose -Restart.
  3. Sign in again with the local administrator account after the restart.
  4. Run Add-Computer -DomainName contoso.com -Credential CONTOSO\Admin -Restart.
  5. Enter the domain password when prompted and let the computer restart.
  6. Sign in with your domain account and check that Group Policy and mapped drives apply.

Domain join depends on correct time on the workstation, because Kerberos fails when clocks drift. If the clock is far off, sync it with the domain controller before you run Add-Computer.

How to check domain trust relationship with PowerShell

  1. Open Windows PowerShell as administrator on the workstation.
  2. Run Test-ComputerSecureChannel -Verbose.
  3. Read the result. True with the message "The secure channel between 'PC01' and 'contoso.com' is alive and working correctly" means the trust is healthy.
  4. Run nltest /sc_query:contoso.com and look for NERR_Success next to Trusted DC Connection Status.
  5. Run set | find /i "LOGONSERVER" in Command Prompt after a domain sign-in to see which DC authenticated you.
  6. On a computer with the Active Directory module, run Get-ADComputer 'PC01' -Properties PasswordLastSet and check the date is today.
Check domain trust relationship with PowerShell Get-ADComputer PasswordLastSet output
Run Get-ADComputer with -Properties PasswordLastSet after a repair; the date should match the day you reset the channel. (Image: Microsoft)

Trust relationship failed keeps coming back

A repair that breaks again within days points at a cause outside the workstation. Microsoft groups the causes by which side holds the newer password.

Trust breaks after a virtual machine snapshot is reverted

The snapshot holds an older computer password than Active Directory.

  1. Check the System log for a gap in event dates or a recent Event ID 12 (Kernel-General) boot.
  2. Run Test-ComputerSecureChannel -Repair -Credential CONTOSO\Admin and restart.
  3. Take a new snapshot after the repair so a later revert does not repeat the problem.

Trust breaks after a system restore or bare metal backup restore

The restore rolled the LSA secret back to an older password.

  1. Look for Event ID 1208 (StartupRepair) in the System log or 8202 (System Restore) in the Application log.
  2. Repair the channel with nltest /sc_reset:contoso.com or the PowerShell command.
  3. Restart the computer.

Trust breaks after a power cut or crash

A password change was lost because the machine did not shut down cleanly.

  1. Look for Event ID 41 (Kernel-Power) or 6008 (EventLog) in the System log.
  2. Repair the secure channel and restart.
  3. On Windows Embedded devices with a write filter, plan password changes for maintenance windows.

Many computers lose trust at once

Active Directory holds the older password, after a DC restore, a replication failure or an authoritative restore of computer objects.

  1. Fix replication and domain controller health first, because the workstations cannot fix this side.
  2. Run repadmin /showobjmeta * "CN=PC01,OU=Computers,DC=contoso,DC=com" and compare pwdLastSet across all DCs.
  3. Once the values match on every DC, reset the secure channel on each affected computer and restart it.

Pooled VDI desktops fail after users sign out

Non-persistent machines reset to an image that carries an old computer password.

  1. Ask the VDI administrator to check that no VDI service stops Netlogon from changing the password.
  2. Update the base image during a maintenance window with nltest /sc_change_pwd:contoso.com.
  3. Consider the Disable machine account password changes policy only for these non-persistent images.

Test-ComputerSecureChannel -Repair says access is denied

PowerShell is not elevated, or the account cannot reset computer passwords in the domain.

  1. Close PowerShell and reopen it with Run as administrator.
  2. Add -Credential CONTOSO\Admin with an account that has rights over the computer object.
  3. Run the repair again.

Repair fails and the computer name looks wrong

The computer name registry values hold a fully qualified domain name instead of the short name.

  1. Run Reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName /v ComputerName.
  2. Run Reg query HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters /v hostname.
  3. If either shows PC01.contoso.com instead of PC01, correct the computer name, then rejoin the domain.
Trust relationship failed keeps coming back: Event ID 12 Kernel-General boot record
A recent Event ID 12 boot record or a gap in event dates points to a reverted snapshot or restore behind the repeat failure. (Image: Microsoft)

Should you disable machine account password changes?

No. Leave Domain member: Disable machine account password changes at its default of Disabled and the password age at about 30 days. Microsoft warns that longer intervals or disabled changes give an attacker more time to guess a machine account password. The setting exists for stockpiled pre-built computers, non-persistent VDI and embedded devices without a writable OS volume, not as a cure for trust errors or dual-boot setups.

Domain trust relationship FAQ

What causes the trust relationship between this workstation and the primary domain to fail?

The computer account password stored on the workstation no longer matches the copy in Active Directory. Snapshot reverts, system restore, backup restores, lost password changes after a crash and Active Directory replication problems are the common reasons.

Can you fix a domain trust relationship without rejoining the domain?

Yes. Run Test-ComputerSecureChannel -Repair -Credential DOMAIN\Admin in an elevated Windows PowerShell window, or nltest /sc_reset:domain in Command Prompt, then restart. Rejoining is only needed when these repairs fail.

Do you need domain admin rights to repair the trust relationship?

You need local administrator rights on the workstation and a domain account that may reset the computer's password. Microsoft's own repair examples run the commands with domain admin credentials passed through the -Credential parameter.

How often does a computer change its domain password?

Every 30 days by default. The interval is set by the Domain member: Maximum machine account password age policy, which accepts 1 to 999 days, and the change is started by the computer, not the domain controller.

Does Test-ComputerSecureChannel work on a domain controller?

No. Microsoft says the cmdlet works only on domain member computers and returns false positive errors on domain controllers. Use netdom resetpwd on the affected DC, or nltest, instead.

Can you still sign in when the trust relationship fails?

Yes, with a local account or cached domain credentials. Microsoft confirms both still work while domain sign-ins fail, so a local administrator account is the usual way in to run the repair.

What event ID shows a broken trust relationship?

Event ID 3210 from source NETLOGON in the System log. It says the computer could not authenticate with a named domain controller, which points to a password mismatch or a duplicate computer name.

Does netdom resetpwd work on a workstation?

No. Microsoft documents netdom resetpwd for resetting a domain controller's own machine account password only, run on that DC. Workstations and member servers use Test-ComputerSecureChannel, Reset-ComputerMachinePassword or nltest.

Philip Celasco

Philip is a Texas-based technology writer and IT administrator at Techdows.com with more than 10 years of experience creating practical content for everyday users and professionals. He specializes in web browsers, particularly Chromium-based platforms such as Google Chrome, Microsoft Edge, Brave, and Opera. Through his work as an IT administrator, Philip has hands-on experience managing devices, configuring browser policies, troubleshooting software and network issues, and helping people resolve problems that affect productivity and security. His articles are based on practical testing and real-world technical experience. He covers browser settings, extensions, performance problems, privacy controls, security features, and Windows troubleshooting. Outside work, Philip enjoys the quieter side of life in Texas and stepping away from the screen when he can. He has two kids, two cats and loves to play golf with his mother during the weekends.

Leave a Reply

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