Setup: A computer member in a domain
Problem: “The trust relationship between this workstation and the primary domain failed”
Solution:
Login with local administrator on the computer and run this command:
Test-ComputerSecureChannel -Repair
If you need to run this command on a remote computer try the following script. Important: You need to know the local admin password for that computer. and PSRemoting should be enabled on that computer.
$rc = "computername"
$remote_local_admin = get-credential ".\Administrator"
Invoke-Command -ComputerName $rc -ScriptBlock { Test-ComputerSecureChannel -repair } -Credential $remote_local_admin