How to find out untrusted workstations?

Ian Xue 37,711 Reputation points Microsoft Vendor
2020-07-16T03:03:46.347+00:00

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
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,561 questions
0 comments No comments
{count} votes

Accepted answer
  1. 2020-07-16T06:02:28.67+00:00

    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

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.