title: Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: 0x80070 6BA
body: <p>I have what should be a simple script that will connect to all the servers in a domain and build a table of all the services running on each server. However, when I try to automate the script to grab all the servers in a foreach loop I get an RPC error. If the $name variable is replaced with the server DNS name everything works as expected. I've checked the firewall and DCOM services on my system (win7) and the servers (2000 - 2008R2) and these are all enabled or disabled appropriately. So, I'm thinking something in the script is broke. I'm still learning powershell, so any tips are appreciated. </p>
  
  <p>Here is the script so far.
       $servernames = get-adobject -Filter 'ObjectClass -eq "Computer" ' -Searchbase       "OU=Servers,DC=E,DC=BENEFIS,DC=ORG"</p>
  
  <pre><code> foreach ($name in $servernames) {
          Get-WMIObject win32_service -computername $name -Property      SystemName,Name,StartName,StartMode | 
          Format-table SystemName, Name, Startname &gt;c:\serverservices.txt }
  </code></pre>