I suspect that your full error output looks like this:
get-wmiobject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
At line:1 char:1
+ get-wmiobject -ComputerName xxx.xxx.xxx.xxx -Class win32_computersystem
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], COMException
+ FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
In this case, the RPC server is the important bit.
Test-Connection relies on ICMP traffic, which will be permitted on most networks, and doesn’t require any special permissions.
In contrast, Get-WMIObject relies on the RPC server, which uses TCP port 135 and may be blocked by your network’s firewall. Additionally, in order to use Get-WMIObject on a remote computer, your user account must be a member of the Administrators group for that computer.
So in this usage Test-Connection will pass normally, but Get-WMIObject may fail due to:
- RPC server not running
- firewall blocking TCP port 135
- user not having admin privileges on remote computer
If you're doing this at home, you may have to adjust your firewall, but #3 may still cause a problem because your user account on one computer won't necessarily be the same on another.
If you're doing this at work... why are you trying to gather data on all the computers on a /24 subnet all at once? and why are you including the gateway in the address range? If #2 is the issue you'll need the help of your local network admin. If #3 is the issue then you probably shouldn't be doing this at all, because it kind of looks like you're trying to probe the network to find out which systems are available on which IP addresses.