title: How to get all computer accounts in an another domain using PowerShell?
body: <p>I am trying to get all computer accounts from the another domain.</p>
  
  <p>Here is my PowerShell script:</p>
  
  <pre><code>$environment = "myDomain"
  $strCategory = "computer"
  $objDomain = New-Object System.DirectoryServices.DirectoryEntry("LDAP://dc=" + $environment + ",dc=com")
  $objSearcher = New-Object System.DirectoryServices.DirectorySearcher ("LDAP://dc=" + $environment + ",dc=com")
  $objSearcher.SearchRoot = $objDomain
  $objSearcher.Filter = ("(objectCategory=$strCategory)")
  $colProplist = "name"
  foreach ($i in $colPropList){$objSearcher.PropertiesToLoad.Add($i)| Out-Null}  
  $colResults = $objSearcher.FindAll()
   foreach ($objResult in $colResults) {
     $objComputer = $objResult.Properties
     Write-output $objComputer.name
  }
  </code></pre>
  
  <p>I am getting this error: </p>
  
  <pre><code>Exception calling "FindAll" with "0" argument(s): "A referral was returned from the server.
  </code></pre>
  
  <p>How can I fix this error? </p>