Confirming computer exists under all domain controllers in a domain?

Christopher Compton 1 Reputation point

I am trying to create a PowerShell script that will confirm what domain controllers are seeing a computer that I am joining to the domain. The reason being is I would like it as a tool to troubleshoot trust relationship issues with computers that are having difficulty joining the domain. I'm unsure how I would go about checking. Obviously I could use something like:

get-addomaincontroller -filter * | Select name

This could be run from the target computer to see all listed domain controllers. But I would more so like to be able to search domain controllers filtering by the computer name of the computer in question because I am mostly troubleshooting the trust issues remotely.

Anybody have any ideas?

Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
3,639 questions
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.
4,627 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Rich Matheisen 35,191 Reputation points

    Get a list of all DCs and use that in a ForEach-Object loop. Use the Get-ADComputer cmdlet to look for the computer name in the filter and add the "-Server" parameter using the name of the DC in the iteration of the loop.

    But this isn't going to help you troubleshoot trusts, or replication. There are GUI and command line tools for that. Here's one of each:


    If you want to use PowerShell, there are ways to do that, too: 326364

    No comments

  2. Andreas Baumgarten 66,066 Reputation points Microsoft MVP

    Hi @Christopher Compton ,

    maybe something like this helps to get started:

    $computer = "test1"  
    Get-ADDomainController | ForEach-Object {  
      try {  
        $compObj = Get-AdComputer -Identity $computer -Server $_.Name -ErrorAction SilentlyContinue  
        if ($compObj) {  
          Write-Host "Computer $computer found on DC $_" -ForegroundColor Green  
      catch {    
        Write-Host "($_)" -ForegroundColor Red  

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Andreas Baumgarten

    No comments