Get-ADDomainController : Directory object not found

Hi

While running below command, getting error message:

Command and error as well

PS C:\temp> $allDCs = (Get-ADForest).Domains | %{ Get-ADDomainController -Filter * -Server $_ }
Get-ADDomainController : Directory object not found
At line:1 char:39
+ $allDCs = (Get-ADForest).Domains | %{ Get-ADDomainController -Filter * -Server $ ...
+                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (:) [Get-ADDomainController], ADIdentityNotFoundException
    + FullyQualifiedErrorId : Directory object not found,Microsoft.ActiveDirectory.Management.Commands.GetADDomainCont
   roller












July 2nd, 2015 10:58am

Hi,

Works just fine for me. Perhaps this will help you track down where your issue is:

(Get-ADForest).Domains | ForEach {

    Write-Host "Checking domain $_" -ForegroundColor Green

    Get-ADDomainController -Filter * -Server $_ | ForEach {

        Write-Host "Checking DC $($_.Name)" -ForegroundColor Green

        $_

    }

}

Free Windows Admin Tool Kit Click here and download it now
July 2nd, 2015 11:12am

Hey!!

I have the same problem, but it works in my test domain and developer domain, but not in the production domain. All 3 domains have the exact same PS Version.

Anyone has any ideas?

Daniel

July 6th, 2015 3:00pm

Hey!!

I have the same problem, but it works in my test domain and developer domain, but not in the production domain. All 3 domains have the exact same PS Version.

Anyone has any ideas?

Daniel

Yes - you should start your own thread. Make sure you've tried what I've already posted.

Free Windows Admin Tool Kit Click here and download it now
July 6th, 2015 3:02pm

I think that may only return one for each domain. 

(Get-ADForest).Domains | %{ (Get-ADDomain -Server $_).replicadirectoryservers}

July 6th, 2015 3:37pm

This might be a little faster.

[system.directoryservices.activedirectory.Forest]::GetCurrentForest().domains | %{$_.DomainControllers.name}

Free Windows Admin Tool Kit Click here and download it now
July 6th, 2015 3:43pm

I think that may only return one for each domain. 

(Get-ADForest).Domains | %{ (Get-ADDomain -Server $_).replicadirectoryse

July 6th, 2015 3:43pm

I think that may only return one for each domain. 

(Get-ADForest).Domains | %{ (Get-ADDomain -Server $_).replicadirectoryse

Free Windows Admin Tool Kit Click here and download it now
July 6th, 2015 3:49pm

remove data? I don't follow.    get-addomaincontroller returns one and I assume he's looking for all. Now for the problem as hand check all your ns records and make sure they are valid as you're supplying domain name in place of server. It'll likely be the first one you're
July 6th, 2015 3:50pm

remove data? I don't follow.    get-addomaincontroller returns one and I assume he's looking for all. Now for the problem as hand check all your ns records and make sure they are valid as you're supplying domain name in place of server. It'll likely be the first one you're
Free Windows Admin Tool Kit Click here and download it now
July 7th, 2015 7:25am

Your proposal does not work either, or I wouldnt state that I had same problem, I would said "Thank you Mike, your solution worked".

July 7th, 2015 9:58am

Your proposal does not work either, or I wouldnt state that I had same problem, I would said "Thank you Mike, your solution worked".

if this doesn't work for you, you have serious problems with your forest.

[system.directoryservices.activedirectory.Forest]::GetCurrentForest().domains | %{$_.DomainControllers.name}

write-host kills puppies as they say.

Free Windows Admin Tool Kit Click here and download it now
July 7th, 2015 10:17am

Your proposal does not work either, or I wouldnt state that I had same problem, I would said "Thank you Mike, your solution worked".

The point was to get you to start your own thread. This thread has already wandered quite off topic.

If you do actually start a thread, make sure you include some detail. Currently your question is unanswerable.

July 7th, 2015 10:56am

write-host kills puppies as they say.

Since this thread has already been threadjacked, I'll tackle this too.

Your statement is generally (like 99.9%) correct, but what to use really depends on the context of what you're doing. If Write-Output had colorization options I'd have stuck with Write-Output, but since this is a completely diagnostic script for interactive use only the use of Write-Host is appropriate here.

You're also making the assumption that all the script should return is the names of the DCs. That requirement was never specified and may not be what the OP is trying to return. Raj is pretty good about not abandoning threads, so hopefully we'll see.

Free Windows Admin Tool Kit Click here and download it now
July 7th, 2015 11:03am

Hey all!!

As you noticed, (on my points if nothing else), I am not the one that have big experience in postings.
And maybe I should have started a new thread, but I have read several forums where people get yelled at for starting a new one when there is one existing.

Bottom down, I have the same problem as this threads first statement.
It worked in all 3 environments, with PS2.0, then I upgraded to PS4.0 on all dcs in all environments, and then it stopped working in my production environment, but still worked in my 2 test environment.
DNS looks fine all over.

Dan, your solution worked, but I needed a little more info than just that (which I should have clearified).
In the end, this one solved it for me, and works in all 3 environents:

((Get-ADForest).Domains |%{ (Get-ADDomain-Server$_).replicadirectoryservers} |%{Get-ADDomainController-Identity$_}) |format-tableName,Domain,Forest,Site,IsGlobalCatalog,IPv4Address,OperatingSystem,OperationMasterRoles,ldapport,sslport-autosize|out-string-width4096

But that still don't answer the question why it stopped working!!

Daniel

July 7th, 2015 11:34am

This thread probably should have been split by a moderator, but no problem.

I don't have PowerShell V4, but it appears that either Get-ADForest or Get-ADDomainController changed. Does the following list the fully qualified domain names in the forest?

(Get-ADForest).Domains

The names should be similar to corp.contoso.com. If the names look correct, then the -Server parameter of Get-ADDomainController may no longer accept the fully qualified name of a domain. Using Get-ADDomain -Server converts the domain names into DC names. I'd lik
Free Windows Admin Tool Kit Click here and download it now
July 7th, 2015 12:04pm

write-host kills puppies as they say.

Since this thread has already been threadjacked, I'll tackle this too.

Your statement is generally (like 99.9%) correct, but what to use really depends on the context of what you're doing. If Write-Output had colorization options I'd have stuck with Write-Output, but since this is a completely diagnostic script for interactive use only the use of Write-Host is appropriate here.

You're also making the assumption that all the script should return is the names of the DCs. That requirement was never specified and may not be what the OP is trying to return. Raj is pretty good about not abandoning threads, so hopefully we'l

July 7th, 2015 12:19pm

Hey all!!

As you noticed, (on my points if nothing else), I am not the one that have big experience in postings.
And maybe I should have started a new thread, but I have read several forums where people get yelled at for starting a new one when there is one existing.

Bottom down, I have the same problem as this threads first statement.
It worked in all 3 environments, with PS2.0, then I upgraded to PS4.0 on all dcs in all environments, and then it stopped working in my production environment, but still worked in my 2 test environment.
DNS looks fine all over.

Dan, your solution worked, but I needed a little more info than just that (which I should have clearified).
In the end, this one solved it for me, and works in all 3 environents:

((Get-ADForest).Domains |%{ (Get-ADDomain-Server$_).replicadirectoryservers} |%{Get-ADDomainController-Identity$_}) |format-tableName,Domain,Forest,Site,IsGlobalCatalog,IPv4Address,OperatingSystem,OperationMasterRoles,ldapport,sslport-autosize|out-string-width4096

But that still don't answer the question why it stopped working!!

Daniel

I can only guess that the problem dc couldn't be contacted at that specific time. That's the problem with Get-ADdomaincontroller..It contacts the DC.  

Free Windows Admin Tool Kit Click here and download it now
July 7th, 2015 12:24pm

Hey Mr Raj!!

We actually figured it out, why it worked in our test environment, but not production, where it worked before.
We implemented WAN optimization appliances, in our case Riverbed, and that's what in the end caused the Get-ADDomainController command to stop working.

So just reaching out checking if you maybe have something similar that blocks or misleads your packets?

Daniel

July 23rd, 2015 11:03am

So, when the code did not work, did the Get-ADDomainController cmdlet no longer accept the fully qualified name of a domain with the -Server parameter? For example:

Get-ADDomainController -Server mydomain.com

failed? I wonder how Riverbed messed that up. I assume it still worked if you specified the fully qualified name of a DC.
Free Windows Admin Tool Kit Click here and download it now
July 23rd, 2015 11:15am

Hey Mr Raj!!

We actually figured it out, why it worked in our test environment, but not production, where it worked before.
We implemented WAN optimization appliances, in our case Riverbed, and that's what in the end caused the Get-ADDomainController command to stop working.

So just reaching out checking if you maybe have something similar that blocks or misleads your packets?

Daniel

July 23rd, 2015 2:58pm

Yes there is Riverbed device between DCs.. but now this issue been solved.. I don't know how??
Free Windows Admin Tool Kit Click here and download it now
August 31st, 2015 1:12pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics