A Referral Was Returned From The Server Powershell Info
PowerShell, unlike the old File Explorer, doesn’t automatically follow that referral. It just reports the server’s note verbatim — like a postal worker handing back a letter saying, “Try the other post office.”
In PowerShell, the error "A referral was returned from the server" typically occurs during Active Directory (AD) operations when the command is querying a Domain Controller (DC) that does not hold the requested data, but knows which other server does. Most standard AD cmdlets do not automatically follow these referrals, leading to this error. Stack Overflow +1 Common Causes & Solutions Querying the Wrong Domain a referral was returned from the server powershell
: Running commands against a Read-Only Domain Controller (RODC) for write operations (like New-ADUser ) may trigger this error as the RODC refers the request to a writable DC. Stack Overflow +1 Common Causes & Solutions Querying
Here’s a short, interesting piece based on that scenario — part tech mystery, part sysadmin humor. # 2. If not found locally
This function automatically detects the target object's domain and connects to the correct domain controller, eliminating the "referral was returned" error for user and computer lookups.
# 2. If not found locally, search the Global Catalog (contains all domains) # We search specifically for the ObjectSid to determine the domain. Write-Verbose "Searching Global Catalog for '$Identity'..." $gcSearcher = [adsisearcher]"(&(objectClass=user)(sAMAccountName=$Identity))" $gcSearcher.SearchRoot = [adsi]"GC://$($env:USERDNSDOMAIN)" $gcResult = $gcSearcher.FindOne()
Write-Verbose "Object found in domain: $targetDomain. Retrieving directly..."