简体   繁体   English

连接到IIS7时出现WMI错误

[英]WMI error when connecting to IIS7

I am getting the same error described here: 我在这里描述了相同的错误:

http://forums.iis.net/p/1033115/1700749.aspx http://forums.iis.net/p/1033115/1700749.aspx

I have a PowerShell cmdlet that tries to control our web application running on Windows Server 2008 SP2 and IIS 7. One of the first things it tries to do is try to connect to the remote machine using WMI. 我有一个PowerShell cmdlet,该cmdlet试图控制在Windows Server 2008 SP2和IIS 7上运行的Web应用程序。它试图做的第一件事就是尝试使用WMI连接到远程计算机。 It does this using code like this: 它使用如下代码执行此操作:

ConnectionOptions connection = new ConnectionOptions();
connection.Authentication = AuthenticationLevel.PacketPrivacy;
this.iisScope = new ManagementScope(@"\\" + this.Name + @"\root\WebAdministration", connection);
this.iisScope.Connect();

this.Name is the server name. this.Name是服务器名称。 This code always works (does not throw an exception), but on the remote machine I get this error in the Windows Event Logs: 此代码始终有效(不会引发异常),但是在远程计算机上,我在Windows事件日志中收到此错误:

Access to the root\\WebAdministration namespace was denied because the namespace is marked with RequiresEncryption but the script or application attempted to connect to this namespace with an authentication level below Pkt_Privacy. 对root \\ WebAdministration命名空间的访问被拒绝,因为该命名空间被标记为RequiresEncryption,但是脚本或应用程序尝试以低于Pkt_Privacy的身份验证级别连接到该命名空间。 Change the authentication level to Pkt_Privacy and run the script or application again. 将身份验证级别更改为Pkt_Privacy,然后再次运行脚本或应用程序。

But as the cmdlet goes on, it does some queries using this.iisScope and they all succeed, and that error is never seen again. 但是,随着cmdlet的进行,它会使用this.iisScope进行一些查询,而所有查询都会成功,并且不会再出现该错误。 I have a guess as to what is going on, but I'm not sure how to prove it. 我对正在发生的事情有一个猜测,但是我不确定如何证明这一点。 I think that it is trying to connect without the Packet Privacy, failing, and then trying to use Packet Privacy. 我认为它正在尝试在没有数据包保密性的情况下进行连接,然后失败,然后尝试使用数据包保密性。 I tried to sniff the packets with Wireshark, but that didn't tell me anything useful. 我试图用Wireshark嗅探数据包,但是并没有告诉我任何有用的信息。

See code in this article: http://learn.iis.net/page.aspx/160/writing-powershell-commandlets-for-iis-70/ . 请参阅本文中的代码: http : //learn.iis.net/page.aspx/160/writing-powershell-commandlets-for-iis-70/ You could also install PowerShell v2 and use get-wmiobject etc. -- they fixed those cmdlets in this release and now you could connect to providers that require encrypted connection, like IIS WMI provider. 您还可以安装PowerShell v2并使用get-wmiobject等。-它们修复了此版本中的这些cmdlet,现在您可以连接到需要加密连接的提供程序,例如IIS WMI提供程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM