Get-WmiObject: RPC server is unavailable on the first query, the second succeed

0

I'm getting the following error "The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)" When I try to gather disk information for servers Windows Server 2008 R2 and later.

The script I wrote and used for a year and more just stopped working since yesterday. Noticed that the first call of Get-WmiObject fails 70% of the time. When I duplicate the variable it is working, but very slow.

It is also working when I execute it manually from a different PowerShell window.

Every time the command get-WmiObject fails on different servers. I have noticed that it is starting to fail after the 15th server from the list and the same is over hundreds.

Here is the part of the code:

$Serverlist = Get-Content .\list.txt
foreach($server -in $serverList){
      Write-Host $server -fo yellow

      $Drives = Get-WmiObject -Class Win32_logicaldisk -Filter "DriveType = '3'" -ComputerName $server | select  DeviceID,Size,Freespace -unique
      $Drives = Get-WmiObject -Class Win32_logicaldisk -Filter "DriveType = '3'" -ComputerName $server | select  DeviceID,Size,Freespace -unique
      
      foreach($drive in $Drives){
            $freegb= [math]::Round($drive.freespace / 1GB, 1)
            $totalgb= [math]::Round($drive.size / 1GB, 1)
            $usedgb= [math]::round(($drive.size - $drive.freespace) / 1GB, 1)
            Write-Host $drive.DeviceID $usedgb $freegb $totalgb
      }
}
  • I can ping the remote servers
  • I have tried with FQDN and IP
  • Tried with different primary DNS
  • RPC services are working on remote servers
  • No firewalls
  • Time is synchronized

the result is the same :(

Noticed also following events 10028 are generated from the workstation where i run the script:

DCOM was unable to communicate with the computer SERVERNAME/IP/FQDN using any of the configured protocols; requested by PID 177c (C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe).

Before i receive "RPC server is unavailable" I receive TCP Retransmission and TCP port numbers reused from the remote server in Wireshark. What that mean and how I can fix it?

Please help :)

powershell
tcp
rpc
powershell-remoting
get-wmiobject
asked on Stack Overflow Jul 28, 2020 by Atilla Hodzholu • edited Jul 29, 2020 by Atilla Hodzholu

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0