title: Invalid Namespace when automating Get-WMIObject
body: <p>I am trying to automate the retrieval of OS architecture and when I do I get an Invalid Namespace error.</p>
  
  <pre><code>    foreach($i in $hosts){
  
           $ip = $i.name
           Get-WmiObject -ComputerName $ip Win32_OperatingSystem
  
      }
  </code></pre>
  
  <p>If I take Get-WmiObject -ComputerName $ip Win32_OperatingSystem and replace $ip with a legit IP it works perfectly. I even added Write-Host to the front of Get-WMIObject so it would display the entire command that would run. I ran the output from Write-Host and the command completes successfully.</p>
  
  <p>Error:
  Get-WmiObject : Invalid namespace 
  At line:4 char:18
  +     Get-WmiObject &lt;&lt;&lt;&lt;  -ComputerName $ip Win32_OperatingSystem
      + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], ManagementException
      + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand</p>
  
  <p>The $hosts variable is a PSCustomObject with two noteProperty fields. The first is name and the second is user. The name field holds an IP address of the system.</p>