I am having some trouble running a script. I keep receiving the error:
"The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)"
Alot of other forums said that this could be a firewall issue, but I don’t think that is the case because I can run invoke-commands such as the following below with no errors:
Get-ADComputer -filter * | Select -expand Name | Get-ComputerInfo
Just so you know, I am not running Windows Firewall in my environment, I am running Symantec Endpoint Protection. All I have done is run a logon script for all computers in the domain with the following code which allowed me to run invoke-commands but not that script:
Enable-PSRemoting -Force
Thank you all for your time and I look forward to your replies!
Invoke-Command uses a different port than RPC, so firewalls could still be involved. If you’re running PowerShell v3 or later on all of your systems, you can try using Get-CimInstance instead of Get-WmiObject. Get-CimInstance, by default, also uses WSMAN (same port as Invoke-Command), so you may have better results that way.
More likely, though, you’re just trying to contact computers that aren’t online when you run the script. Odds are that your AD domain contains at least some computer accounts that are either old (for machines that have been turned off or replaced), for laptops that are offline, etc. You can add some Write-Verbose or Write-Debug statements to your script to find out what’s in the $computername variable when you encounter the errors, and you can add some error handling to gracefully deal with a situation where a target computer is offline.
I did not realize that Invoke-Command uses a different port. If that is the case, then it seems most likely to be that I must open up port 5985 on the firewall to allow winRM.
Steven.
Thank you for the formatting tip, I will change the function now.
If Invoke-Command works, then 5985 is already open RPC uses many different ports (including a dynamic range). It’s very unfriendly to firewalls, which is one of the things that led to Microsoft adopting WSMAN later on.
Damn, well that sucks. I’m assuming there is a list of these ports somewhere. It now seems I have either allow all those ports or update everyone to v3 of Powershell. Right now, everyone is on v2.
In my environment, I get that error for a number of reasons. One as Dave Wyatt has pointed out is that the asset is powered off. The other reasons that I see in my environment are:
if you have preboot authentication and the asset is not completely past the preboot screen.
if you asset is hung after applying patches or an install (this typically happens to a few machines during the application of patches around “Patch Tuesday”
The last and more prevalent reason is that WMI is hosed on that asset and needs to be repaired.
I do have to say that i have begun to replace all my Get-WMIObject with Get-CimInstance and am very pleased.
I actually now believe there could be some other cause.
Just as a test, I turned off Network Threat Protection on Symantec for a specific client I was encountering this error with. I attempted to run the command again on it and I STILL encountered this RPC error.
I ensured the PC had winRM running, DCOM, and RPC service all running.
Just to clarify. I can also enter-pssession with these machines as well. The only time I encounter an error is when I try to run this script or attempt to run a command like
Get-WmiObject Win32_Bios -ComputerName blahlbah
It then throws up the RPC server is unavailable error.
I’d like to change to use the Get-CimInstance, but all my machines in the domain are v2. I don’t know the easiest method to update all of them to v4.
Still sounds like a straightforward firewall problem to me. RPC ports are being blocked, WinRM port is allowed. I suppose, in a pinch, you might just try this: