title: how can I query to multiple domain's computer account in powershell
body: <p>I have bulk computer list in my CSV file with header of servers.</p>
  
  <p>All these servers are different domains under single forest.</p>
  
  <p>I need to get all these server attribute details like name and operating system, status.</p>
  
  <p>I have created below script but that's not working..</p>
  
  <p>Any help would be appreciated.</p>
  
  <pre><code>Import-Module ActiveDirectory
  
  # For each domain in the forest
  
  $domains = (Get-ADForest).Domains
  $servers = Import-Csv "D:\temp\computer.csv" | % {$_.server}
  
  foreach ($server in $servers)
  {
    foreach ($domain in $domains)
    {
      Get-ADComputer $server -Server $domain -Properties operatingsystem | select name,operatingsystem 
    }
  }
  </code></pre>
  
  #
  
  <p>HI</p>
  
  <p>I have added my script like below:</p>
  
  #
  
  <pre><code>Import-Module ActiveDirectory
  
  
  
  # For each domain in the forest
  
  
  
  $domains = (Get-ADForest).Domains
  
  $servers = Import-Csv "D:\temp\computers.csv" | % {$_.server}
  
  $DomainController = "DC2:3268"  #  3268 is the commen port of global catalogue
  
  $SearchBase = ((Get-ADDomain (Get-ADForest).RootDomain).DistinguishedName)
  
  foreach ($server in $servers)
  
  {
  
  foreach ($domain in $domains)
  
  {
  
  Get-ADComputer $server -Server $DomainController -SearchBase $SearchBase -Properties operatingsystem | select name,operatingsystem
  
  }
  }
  </code></pre>
  
  #
  
  <p>Getting below error now and also I have specified only samaccountname of computer not FQDS this time..</p>
  
  #### Error
  
  <pre><code>Get-ADComputer : A positional parameter cannot be found that accepts argument 'DPS002'.
  At D:\temp\search_computer.ps1:34 char:5
  +     Get-ADComputer $server -Server $DomainController -SearchBase $SearchBase -Pr ...
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidArgument: (:) [Get-ADComputer], ParameterBindingException
      + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Management.Commands.GetADComputer
  </code></pre>