适用于 IIS 的 Windows PowerShell 管理单元在 32 位上失败?
我正在尝试编写一个 PowerShell 脚本来自动执行 IIS 网站部署。我尝试在 32 位 Windows Server 2008 R2 计算机上运行脚本:
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
每当我运行如下所示的 WebAdministration 命令时:
Get-Website -Name "MYWebsite"
我收到如下错误:
Get-Website : Retrieving the COM class factory for component with CLSID {688EEE
E5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: 80040154.
At line:1 char:12
+ Get-Website <<<< -Name "MyWebsite"
+ CategoryInfo : NotSpecified: (:) [Get-Website], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Micr
osoft.IIs.PowerShell.Provider.GetWebsiteCommand
Switching to the 64-bit version of PowerShell.exe解决了这个问题,但使我无法同时使用 Microsoft Team Foundation Server 2008 Power Tools PSSnapin,这对我来说是不行的。
知道我该如何克服这个问题吗?提前致谢。
I'm trying to write a PowerShell script that will automate my IIS website deployments. I'm trying to run the scripts on my Windows Server 2008 R2 machine, under 32-bit in:
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
Whenever I run a WebAdministration command such as this:
Get-Website -Name "MYWebsite"
I get an error like this:
Get-Website : Retrieving the COM class factory for component with CLSID {688EEE
E5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: 80040154.
At line:1 char:12
+ Get-Website <<<< -Name "MyWebsite"
+ CategoryInfo : NotSpecified: (:) [Get-Website], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Micr
osoft.IIs.PowerShell.Provider.GetWebsiteCommand
Switching to the 64-bit version of PowerShell.exe resolves this issue but makes it impossible for me to also use the Microsoft Team Foundation Server 2008 Power Tools PSSnapin, which is a no-go for me.
Any idea how I can overcome this? Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
运行:
实际上加载了 32 位版本的 powershell ;-)
这显然不是你想要的。运行system32中的版本以获得64位版本。是的,真的。
您可以这样验证:
如果返回 4,则它是 32 位。 64 位 powershell 将返回 8。
-Oisin
Running:
actually loads the 32 bit version of powershell ;-)
This obviously not what you want. Run the version in system32 to get the 64bit version. Yes, really.
You can verify this like:
If it returns 4, it's 32 bit. 64 bit powershell will return 8.
-Oisin
您可能会尝试的一件事是按照 Oisin 的说法加载 64 位 PowerShell,然后使用 Start-Job -RunAs32 执行加载 TFS PowerTools 管理单元并根据需要执行 TFS cmdlet 的脚本。确保从后台作业中运行的命令输出所需的信息。使用 Wait-Job 等待其完成,然后使用 Receive-Job 将数据从 32 位端获取回主 64 位 PowerShell 会话,例如
One thing you might try is to load up a 64-bit PowerShell as Oisin says and then use Start-Job -RunAs32 to execute script that loads the TFS PowerTools snapin and executes the TFS cmdlets as necessary. Be sure to output an required info from the commands that run in the background job. Use Wait-Job to wait for it to complete then use Receive-Job to get the data from the 32-bit side back into your main 64-bit PowerShell session e.g.
使用以下命令打开 powershell 解决了我的问题:
只需使用上述命令调用 powershell 64 位版本,并将带有参数的脚本路径传递给它。
Opening powershell with the below command solved my issue :
Just invoke the powershell 64 bit version with the above command and pass the script path with arguments to it.
对于那些将来发现此问题的人,我想补充一点,您应该仔细检查启动 powershell 的方式。我遇到了同样的错误,并且无法弄清楚为什么解决方案全部参考使用 64 位版本,而我认为我已经是了。
事实证明,因为我使用第三方 32 位启动器运行 powershell,所以尽管是从 system32 文件夹启动的,但 powershell 仍会回退到 32 位可执行文件。感谢 x0n 提供了确认我正在使用的版本的方法,因为这引导我找到了我的解决方案。
For those finding this in the future, I'd like to add that you should double check how you launch powershell. I was getting the same error, and couldn't figure out why the solutions were all in reference to using the 64 bit version, when I thought I already was.
It turns out that because I was running powershell with a third party 32 bit launcher, powershell was falling back to the 32 bit executable, despite being launched from the system32 folder. Thanks to x0n for the method of confirming the version I was using, as this lead me to my solution.
只是为了连接点。 “urig”在另一个主题中回答了他自己的问题:
TFS Power Tools 2008 Powershell Snapin 无法在 64 位 Windows 2008 R2 中运行
“Microsoft 的 Cathy Kong 非常友善为我提供此问题的解决方法。完整的详细信息可以在 MSDN TFS PowerTools 论坛中找到:http://social.msdn.microsoft.com/Forums/en-US/tfspowertools/thread/a116799a-0476-4c42- aa3e-45d8ba23739e/?prof=required
修复如下,对我来说效果很好:
请保存以下内容并将其另存为 *.reg 文件并导入到注册表(只需双击 *.reg 文件,单击“确定”双击)
Windows 注册表编辑器版本 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns\Microsoft.TeamFoundation.PowerShell] "PowerShellVersion"="2.0" "Vendor"="Microsoft Corporation" "Description"="This is包含 Team Foundation Server cmdlet 的 PowerShell 管理单元。" "VendorIndirect"="Microsoft.TeamFoundation.PowerShell,Microsoft" "DescriptionIndirect"="Microsoft.TeamFoundation.PowerShell,这是包含 Team Foundation 的 PowerShell 管理单元服务器 cmdlet。" "Version"="10.0.0.0" "ApplicationBase"="C:\Program Files (x86)\Microsoft Team Foundation Server 2010 Power Tools" "AssemblyName"="Microsoft.TeamFoundation.PowerTools.PowerShell, Version= 10.0.0.0、文化=中性、PublicKeyToken=b03f5f7f11d50a3a" "ModuleName"="C:\Program Files (x86)\Microsoft Team Foundation Server 2010 Power Tools\Microsoft.TeamFoundation.PowerTools.PowerShell.dll" "CustomPSSnapInType"="Microsoft .TeamFoundation.PowerTools.PowerShell.TFPSSnapIn”
Just to connect the dots. "urig" answered his own question in another topic:
TFS Power Tools 2008 Powershell Snapin won't run in on 64-bit in Windows 2008 R2
"Cathy Kong of Microsoft was kind enough to provide me with a workaround for this issue. The full details can be found here in the MSDN TFS PowerTools forum: http://social.msdn.microsoft.com/Forums/en-US/tfspowertools/thread/a116799a-0476-4c42-aa3e-45d8ba23739e/?prof=required
The fix is as follows and worked well for me:
Please save the following content and save it as *.reg file and import to Registry(just double click the *.reg file, click OK double)
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns\Microsoft.TeamFoundation.PowerShell] "PowerShellVersion"="2.0" "Vendor"="Microsoft Corporation" "Description"="This is a PowerShell snap-in that includes the Team Foundation Server cmdlets." "VendorIndirect"="Microsoft.TeamFoundation.PowerShell,Microsoft" "DescriptionIndirect"="Microsoft.TeamFoundation.PowerShell,This is a PowerShell snap-in that includes the Team Foundation Server cmdlets." "Version"="10.0.0.0" "ApplicationBase"="C:\Program Files (x86)\Microsoft Team Foundation Server 2010 Power Tools" "AssemblyName"="Microsoft.TeamFoundation.PowerTools.PowerShell, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" "ModuleName"="C:\Program Files (x86)\Microsoft Team Foundation Server 2010 Power Tools\Microsoft.TeamFoundation.PowerTools.PowerShell.dll" "CustomPSSnapInType"="Microsoft.TeamFoundation.PowerTools.PowerShell.TFPSSnapIn"