rpc wmi 服务不可用_“RPC服务器不可用”使用WMI查询

我有一个运行Server 2008 R2的Web服务器工作组,我试图管理一个检查所有这些磁盘空间的脚本。几个月前,我在设置服务器时设置了这一点,我相信它工作正常。现在我去检查,它给出了一个错误,说“RPC服务器不可用”。该脚本是一个C#ASP.NET页面,虽然我尝试过在PowerShell中进行类似的调用,但它给出了相同的错误。该脚本正常工作以访问本地计算机的信息,但无法访问远程服务器信息。“RPC服务器不可用”使用WMI查询

我已经花了最后几个小时挖掘我能找到的所有东西,但没有任何工作。我为WMI(远程&本地),DCOM(远程&本地)以及我正在访问的计算机的整个驱动器设置了权限。我使用了计算机名称,IP地址,完整的计算机名称(xxx.echomountain.com),并在ConnectionOptions对象上尝试了大量的模拟和身份验证设置。

我知道用户名/密码,我使用的是正确的,因为我可以从别的什么其他

任何想法访问一个的碎片目录,我可以检查可能导致这个错误?

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

2011-03-07

jwynveen

+0

我得到相同的错误,但它是非常随机的,我的意思是有时我得到这个错误,有时我没有。它看起来取决于我使用的登录类型。你如何登录?域帐户? –

2012-03-23 16:00:25

+0

我的登录在每台服务器上单独设置,但它们共享相同的凭据。我真的放弃了解决这个问题。如果你有工作,即使是间歇性的,我也会对你如何做这件事感兴趣。 –

2012-03-23 19:43:41

+0

假设您的脚本在域计算机上运行,​​您应该没有任何问题,而如果您在域外运行,请尝试使用DOMAIN \\用户名作为用户名。如果我使用DOMAIN \\用户名作为登录,我不会收到错误(大部分时间)。 –

2012-03-24 09:57:22

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值