question

IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT asked YoungYang-MSFT answered

How to find out untrusted workstations?

I often see the following error

“The trust relationship between this workstation and the primary domain failed”

How can i find out these error workstations by powershell or other script?

https://social.technet.microsoft.com/Forums/windowsserver/en-US/1cfd5e0a-523a-4912-a3e4-2deee81ffe83/how-to-find-out-untrusted-workstations65311?forum=winserverDS

windows-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

YoungYang-MSFT avatar image
0 Votes"
YoungYang-MSFT answered

Hi,

You can easily check all computers in AD on a regular schedule and generate a report by using the AD PowerShell module, a loop, and the Test-ComputerSecureChannel command.

$localCredential = Get-Credential


@(Get-AdComputer -Filter *).foreach({


 $output = @{ ComputerName = $_.Name } 

  

 if (-not (Test-Connection -ComputerName $_.Name -Quiet -Count 1)) { $output.Status = 'Offline' 

     } else { 

  

     $trustStatus = Invoke-Command -ComputerName $_.Name -ScriptBlock { Test-ComputerSecureChannel } -Credential $localCredential 

     $output.Status = $trustStatus 

 } 

  

 [pscustomobject]$output 


})

Running this returns an output that looks like this:

ComputerName Status



COMPUTER1 Offline

COMPUTER2 True

COMPUTER3 False

COMPUTER4 True

Plus, you can get more information by visiting the link:

https://theitbros.com/fix-trust-relationship-failed-without-domain-rejoining/

https://4sysops.com/archives/repair-the-domain-trust-relationship-with-test-computersecurechannel/

Hope these can help you.

best wishes,

Young Yang

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.