I have a workgroup of web servers running Server 2008 R2 in which I'm trying to manage a script that checks the disk space of all of them. I had set this up a few months ago when the servers were being set up and I believe it was working fine. Now I go and check and it's giving an error saying "The RPC server is unavailable". The script is a C# ASP.NET page, though I've tried comparable calls in PowerShell and it gives the same error. The script works fine to access the information for the local machine, but can't access remote server info.
I've spent the last few hours digging through everything I can find, but nothing works. I've set permissions for WMI (remote & local), DCOM (remote & local), and the whole drive of the computer I'm accessing. I've used the computer name, IP address, full computer name (xxx.echomountain.com), and tried numerous impersonation and authentication settings on the ConnectionOptions object.
I know the username/passwords I'm using are correct since I can access the shard directories of one from the other
Any ideas of what else I could check that might cause this error?
ConnectionOptions oConn = new ConnectionOptions();
oConn.Impersonation = ImpersonationLevel.Impersonate;
oConn.EnablePrivileges = true;
oConn.Username = username;
oConn.Password = password;
//oConn.Authentication = AuthenticationLevel.PacketPrivacy;
string strNameSpace = @"\\";
if (srvname != "")
strNameSpace += srvname + ".echomountain.com";
else
strNameSpace += ".";
strNameSpace += @"\root\cimv2";
ManagementScope oMs = new ManagementScope(strNameSpace, oConn);
//get Fixed disk state
ObjectQuery oQuery = new ObjectQuery("select FreeSpace,Size,Name from Win32_LogicalDisk where DriveType=3");
//Execute the query
ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(oMs, oQuery);
//Get the results
ManagementObjectCollection oReturnCollection = oSearcher.Get();
//loop through found drives and write out info
double D_Freespace = 0;
double D_Totalspace = 0;
foreach (ManagementObject oReturn in oReturnCollection)
{
// Disk name
//MessageBox.Show("Name : " + oReturn["Name"].ToString());
// Free Space in bytes
string strFreespace = oReturn["FreeSpace"].ToString();
D_Freespace = D_Freespace + System.Convert.ToDouble(strFreespace);
// Size in bytes
string strTotalspace = oReturn["Size"].ToString();
D_Totalspace = D_Totalspace + System.Convert.ToDouble(strTotalspace);
boxSize = (D_Totalspace / GB).ToString("##.00");
boxFree = (D_Freespace / GB).ToString("##.00");
Response.Write(srvname + ":" + boxSize + ":" + boxFree);
}
Server Error in '/' Application.
The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
Source Error:
Line 64: Line 65: //Get the results Line 66: ManagementObjectCollection oReturnCollection = oSearcher.Get(); Line 67: Line 68: //loop through found drives and write out info
Source File: c:\Web\medelaimages.com\iis\tool\boxinfoagent.aspx Line: 66
Stack Trace:
[COMException (0x800706ba): The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)] System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) +0 System.Management.ManagementScope.InitializeGuts(Object o) +674 System.Management.ManagementScope.Initialize() +347 System.Management.ManagementObjectSearcher.Initialize() +189 System.Management.ManagementObjectSearcher.Get() +54 ASP.tool_boxinfoagent_aspx.Page_Load(Object sender, EventArgs e) in c:\Web\medelaimages.com\iis\tool\boxinfoagent.aspx:66 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25 System.Web.UI.Control.LoadRecursive() +71 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3048
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
The error The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
can occur if
inbound RPC / WMI connections are blocked on the target machine due to Firewall restrictions
or
just because you entered incorrect hostname / IP address of the target machine.
The error occurs before any authentication and/or authorization actions, so dealing with permissions is not required at this step. In fact, if the user account lacks necessary permissions to a particular namespace, you'd get another error and errorcode: access denied. (0x80041003)
.
The MSDN article covers adding Firewall exceptions for remote WMI access: "Connecting to WMI Remotely".
The error message is telling you that RPC is blocked, which is the default policy setting on Windows 7 and 2008. Either open it via policy, or use WMI to connect and manage the hosts. On an internal, trusted network, RPC is usually enabled. US government computer security policy boards, like those that created FDCC and USGCB, have no recommended setting for RPC, so it is ok to enable it. Managing live systems via WMI is very difficult since you cannot view remote hosts' registry, scheduled tasks, folders and files. You can, however, easily manage services via WMI.
Just Go to IIS manager. Start your website Service in Application pool. It works for me
Also, You need to enable Windows Management Instrumentation (WMI) rule in windows firewall on remote machine.
1] Open Windows Firewall.
2] Click on Allow app or feature through windows firewall.
3] Enable Privilege for Windows Management Instrumentation(WMI).
I faced same issue. Earlier I was getting this error while using server IP but was able to connect after I used server FQDN name. After troubleshooting I found my DNS PTR record was not correct. After fixing that I was able to connect WMI with IP address also. I used wbemtest WMI test tool.
User contributions licensed under CC BY-SA 3.0