How to fix “the trust relationship between this workstation and the primary domain failed”

If you’ve restored or “rolled back” a PC running Windows 7, Windows 8, or Vista then you may have run into this error message  “the trust relationship between this workstation and the primary domain failed”.
In order to fix this the first thing you need to do is login with a local account as opposed to a domain account.  The reason for this is simple, the server no longer trusts you so you can’t authenticate any domain users.
To do this on Windows7 for the username you will need to use .administrator or .USERNAME  (where USERNAME) is a valid local user name.  Unfortunately if you do not know these then you must use a Windows7 password reset utility first.
Once you have logged in as a local user you need to download RSAT for windows7 this will allow you to run the netdom command-
Once it is downloaded you must go into the control panel to actually enable it.  Go to add remove windows components then browse to this location.
In the treeview, go to Remote Server Administration Tools -> Role Administration Tools -> AD DS and AD LDS Tools and select AD DS Tools. Click OK.
Once this is complete run the following command to reset the trust with your server
netdom.exe resetpwd /s:DomainControllerName /ud:domainDomainAdmin /pd:* 
Replace DomainControllerName with the name of a valid domain controller and replace domainDomainAdmin with your domain name and valid domain administrator account.  You are now finished.  Reboot the PC.
There is also a second method for fixing this error.  It is to login as a local administrator account remove the PC from the domain reboot and then add it back.  This will however reset your users’ profiles.