Uncategorized · April 27, 2021 0

Get-ADComputer : A referral was returned from the server

Hi and welcome to the powermator,

probably you are here because you were using Get-ADComputer and PowerShell threw an error looking like below

there are many reasons this error might happen but here I want to point out that when you use the -searchBase to search in a specific OU, PowerShell might get confused in Forest scenarios and threw this error. Here I want to share with you a small workaround to get over that.

My workaround involves telling PowerShell where exactly to search. In another word, you tell where your OU is expected to be found. So simply I modify the above code to something like below


(Get-ADComputer -Filter * -Server "something.someDomain.net" -SearchBase "OU=windows 10,OU=ou_computer,DC=something,DC=someDomain,DC=net" | select Name).count

and with that you get your error disappeared : )

Thats it!

Happy coding

Jaber

Close Bitnami banner
Bitnami