Fix the trust relationship between this workstation and the primary domain failed: test the secure channel, repair it with Test-ComputerSecureChannel -Repair or nltest /sc_reset, reset the machine password, find the cause, or rejoin.
Home › Guides › Trust relationship failed
Last updated 18 November 2026
The computer's secure channel to the domain is broken: the computer account password stored on the machine no longer matches the one in Active Directory. Domain sign-ins fail, but a local account or cached credentials still work. Sign in with a local administrator account and, from an elevated prompt, run one of these with domain admin credentials (Microsoft's fix), then restart:
nltest /sc_reset:domain_name
Test-ComputerSecureChannel -Repair -Credential *
Run the PowerShell command in Windows PowerShell 5.1 (powershell.exe). Microsoft lists Test-ComputerSecureChannel, Reset-ComputerMachinePassword, Add-Computer and Remove-Computer among the cmdlets removed from PowerShell 7. If the repair doesn't work, reset the machine password; rejoining the domain is the last resort. If it keeps happening, find the cause before you fix it again.
NlSessionSetup: Session setup: cannot I_NetServerAuthenticate 0xc0000022 and new password is bad, try old one.nltest /sc_query:contoso.com reports Trusted DC Connection Status Status = 5 0x5 ERROR_ACCESS_DENIED.The 3210 text names another computer using the same name as one possible cause. If you suspect that, find the other device's MAC address in your DHCP leases or ARP table and identify its vendor with the MAC Vendor Lookup. Look up 3210 and the other events below in the Windows Event ID Lookup.
set | find /i "LOGONSERVER" in cmd.exe. Check you can reach it, for example with Test-Connection to its fully qualified name. If there is no connectivity, fix the network path first.Test-ComputerSecureChannel returns $true if the channel works and $false if not; add -Verbose for detail or -Server "DCName.fabrikam.com" to test against a specific DC:
Test-ComputerSecureChannel -Verbose VERBOSE: "The secure channel between 'SERVER01' and 'net.fabrikam.com' is alive and working correctly."
The cmdlet uses the NetLogon service, like NetDom.exe. It only works on domain member computers: Microsoft says it returns false positive errors on domain controllers, so use netdom.exe or nltest.exe to check and reset a DC's secure channel.
Test-ComputerSecureChannel -Repair -Credential *
or from cmd.exe:
nltest /sc_reset:domain_name
Use domain admin credentials and restart the computer afterwards. Microsoft's Azure VM article runs the same sequence: test, repair, then reset the machine password, then rejoin.
Reset-ComputerMachinePassword changes the computer account password the computer uses to authenticate to domain controllers. Microsoft's examples:
Reset-ComputerMachinePassword -Server "DC01" -Credential Domain01\Admin01
Or on a remote computer you can still reach with PowerShell remoting:
$cred = Get-Credential
Invoke-Command -ComputerName "Server01" -ScriptBlock {
Reset-ComputerMachinePassword -Credential $Using:cred
}If the channel still won't come back, remove the computer from the domain and join it again (Microsoft's examples):
Remove-Computer -UnjoinDomaincredential Domain01\Admin01 -PassThru -Verbose -Restart Add-Computer -ComputerName Server01 -LocalCredential Server01\Admin01 -DomainName Domain02 -Credential Domain02\Admin02 -Restart -Force
Microsoft calls rejoining a valid solution but notes it won't tell you why the channel broke. Keep a local administrator account with a strong, unique password (make one with the UUID / Password Generator) so you can still sign in when the trust fails.
Microsoft's data collection steps compare two timestamps:
cupdtime. Only SYSTEM can read HKLM\SECURITY by default, so run reg query "HKLM\SECURITY\Policy\Secrets\$MACHINE.ACC\CupdTime" in the System context (Microsoft suggests PsExec). Reverse the byte order of the hex value, convert it to decimal and run w32tm /ntte on it. Microsoft's example: 26A38C1AA0F4DA01 becomes 01DAF4A01A8CA326, which is 133688107438220070, which w32tm /ntte shows as 8/22/2024 7:32:23 AM.pwdLastSet. Run Get-ADComputer '<ComputerName>' -properties PasswordLastSet | Format-List, or repadmin /showobjmeta * "CN=ComputerName,OU=Computers,DC=domain,DC=com" to see the value on every DC. It should be the same on all of them.| Result | Common causes (Microsoft) | Fix |
|---|---|---|
| Active Directory has the newer password | The VM was reverted to an old snapshot; the machine was restored from a bare metal backup or an old system restore point (System event 1208 or Application event 8202); an unexpected shutdown or power outage (events 41 or 6008) lost the change; pooled VDI desktops or machines built from an image with old secure channel data. | Reset the secure channel on the computer (nltest /sc_reset or Test-ComputerSecureChannel -Repair -Credential *) and restart. VDI cases go to the VDI administrator. |
| The computer has the newer password | Active Directory replication problems, a domain controller recovered from backup, or an authoritative restore of the computer object. | Fix it on the Active Directory side first (replication, DC health, network); it can't be fixed from the client. Then reset the secure channel and reboot. |
A snapshot revert leaves no specific event. Microsoft suggests looking for jumps in time in the System log (its example is events jumping from February to July on a machine in constant use) and checking Event ID 12 (Kernel-General, The operating system started at system time) or the uptime for a recent start. Microsoft also says to make sure these registry values hold the computer's short name, not its FQDN:
Reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName /v ComputerName Reg query HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters /v hostname
Searching an exported netlogon.log for NlSessionSetup or NlChangePassword lines is quicker with a pattern; test one in the Regex Tester. More AD cmdlets are in the PowerShell Cheat Sheet.
Look up NETLOGON and System event IDs in the Windows Event ID Lookup, find more AD and computer cmdlets in the PowerShell Cheat Sheet, identify the vendor of a device that may be reusing the computer's name with the MAC Vendor Lookup, check a VM's address against the DC subnet with the IPv4 Subnet Calculator, test netlogon.log search patterns in the Regex Tester and create a strong local administrator password with the UUID / Password Generator. Related guides: find the source of an account lockout (4740), Event ID 4625 status and sub status codes and Netlogon event 5719.
The secure channel between the computer and its domain is broken because the computer account password on the machine and in Active Directory no longer match. Microsoft's common causes are a machine with an older password (snapshot revert, backup or system restore, power loss) or Active Directory with an older password (replication problems or a restored DC).
Sign in with a local administrator account and run nltest /sc_reset:domain_name, or Test-ComputerSecureChannel -Repair -Credential * in Windows PowerShell 5.1, with domain admin credentials, then restart. If that fails, try Reset-ComputerMachinePassword.
It is a Windows PowerShell 5.1 cmdlet. Microsoft lists it, along with Reset-ComputerMachinePassword, Add-Computer and Remove-Computer, among the cmdlets removed from PowerShell 7, so run it in powershell.exe rather than pwsh.
No. Microsoft says it only works on domain member computers and returns false positive errors on domain controllers. Use netdom.exe or nltest.exe to check and reset a domain controller's secure channel.
Compare the computer's cupdtime and Event 5823 with the pwdLastSet value in Active Directory. If Active Directory is newer, look for snapshot reverts, restores, power loss or VDI images. If the computer is newer, check Active Directory replication and restored domain controllers.
Runbooks, checklists and helpdesk templates: IT Admin Packs on Gumroad.