Powershell - Windows 更新后创建 ServerManager 对象时出错
您好,
我有一个 powershell 部署脚本,它将文件从 svn 下载到目录中,然后更新 IIS 设置以将站点指向新文件夹。它一直运行良好,直到对服务器进行了一些更新。现在,当我尝试运行该脚本时,它出错了。
[Void][Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration")
$serverManager = New-Object Microsoft.Web.Administration.ServerManager
错误是
New-Object : Exception calling ".ctor" with "0" argument(s):
"Retrieving the COM class factory for component with CLSID {B15183DD-75F9-42DF-8E57-C8B57692F134} failed due to the following error: 80040154."
At C:\Users\administrator.LAYERXNETWORKS\AppData\Local\Temp\2\e72ec49f-353f-4dc0-877c-ef67f6b49bab.ps1:2 char:28
+ $serverManager = New-Object <<<< Microsoft.Web.Administration.ServerManager
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
我读到此错误通常是由于未安装该类引起的。
服务器运行 Windows 2008 R2 和 IIS 7.5
HI,
I have a powershell deployment script that downloads files from svn into a directory and then updates the IIS settings to point the site at the new folder. It has been running fine, until some updates were made to the server. Now, when I try and run the script it errors out on
[Void][Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration")
$serverManager = New-Object Microsoft.Web.Administration.ServerManager
The error is
New-Object : Exception calling ".ctor" with "0" argument(s):
"Retrieving the COM class factory for component with CLSID {B15183DD-75F9-42DF-8E57-C8B57692F134} failed due to the following error: 80040154."
At C:\Users\administrator.LAYERXNETWORKS\AppData\Local\Temp\2\e72ec49f-353f-4dc0-877c-ef67f6b49bab.ps1:2 char:28
+ $serverManager = New-Object <<<< Microsoft.Web.Administration.ServerManager
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
I ahve read that this error is generally caused by the class not being installed.
The server is running Windows 2008 R2 with IIS 7.5
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
确保加载正确的按位版本的 PowerShell。如果您运行的是 64 位版本,那么您将收到所描述的异常。
您需要使用 32 位 (Windows PowerShell (x86)) 版本的 PowerShell 来使用
Microsoft.Web.Administration
。Make sure you load the correct bit-wise version of PowerShell. If you're running the 64 bit version then you'll get the exception described.
You need to use the 32bit (Windows PowerShell (x86)) version of PowerShell to consume
Microsoft.Web.Administration
.作为答案的补充,我发现使用 x86 powershell 控制台存在问题,最终发现使用
而不是
它运行良好。
Just as an extra to the answer, I found issues with using the x86 powershell console, and in the end found that using
rather than
It ran fine.