I tried to logon to a computer that wasn’t used for 18 months.
I got message “The trust relationship between primary domain and this workstation failed” while logging on.
A few PowerShell commands helped to fix the issue:
Solve the problem by resetting the Computer password in Active Directory and on the Local machine, for this we use a PowerShell CMDlet called Reset-ComputerMachinePassword. Type in the following command:
Reset-ComputerMachinePassword -Server <Name of any domain controller> -Credential <domain admin account>
or
NETDOM RESETPWD /Server:<name of any domain controller> /UserD:<domain admin account> /PasswordD:<password>