【问题标题】:Windows PowerShell Snap-In for IIS fails on 32-bit?用于 IIS 的 Windows PowerShell 管理单元在 32 位上失败?
【发布时间】:2010-08-17 09:20:18
【问题描述】:

我正在尝试编写一个 PowerShell 脚本来自动化我的 IIS 网站部署。我正在尝试在我的 Windows Server 2008 R2 机器上运行脚本,在 32 位以下:

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

切换到 64 位版本的 PowerShell.exe 解决了这个问题,但我无法同时使用 Microsoft Team Foundation Server 2008 Power Tools PSSnapin,这对我来说是不行的。

知道如何克服这个问题吗?提前致谢。

【问题讨论】:

标签: iis powershell tfs-power-tools web-admin


【解决方案1】:

跑步:

C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe 

实际上加载了 32 位 版本的 powershell ;-)

这显然不是你想要的。运行system32中的版本,得到64位版本。对真的。

你可以这样验证:

ps> [intptr]::size
4

如果返回 4,则为 32 位。 64 位 powershell 将返回 8。

-奥辛

【讨论】:

  • 我认为他遇到的问题是他想将 TFS 管理单元(仅限 32 位)与 似乎为 64 位的 WebAdmin 模块结合使用仅限。
【解决方案2】:

您可能会尝试的一件事是按照 Oisin 的说明加载 64 位 PowerShell,然后使用 Start-Job -RunAs32 执行加载 TFS PowerTools 管理单元并在必要时执行 TFS cmdlet 的脚本。请务必从后台作业中运行的命令输出所需的信息。使用 Wait-Job 等待它完成,然后使用 Receive-Job 将数据从 32 位端获取回您的主 64 位 PowerShell 会话,例如

PS> [IntPtr]::Size
8
PS> $job = Start-Job { [intptr]::size } -RunAs32
PS> Wait-Job $job

Id              Name      State      HasMoreData     Location     Command
--              ----      -----      -----------     --------     -------
3               Job3      Completed  True            localhost    [intptr]::size


PS> Receive-Job $job
4

【讨论】:

  • 再次感谢基思让我直截了当。我已经编辑了我的问题以反映您的更正。我仍然不知道如何让 IIS PSProvider 和 TFS Power Tools PSSnapin 一起工作。有什么想法吗?
  • 我知道无法在 same PowerShell 会话中加载 32 位管理单元作为 64 位管理单元。除了我的回答中解释的使用 32 位后台作业。
【解决方案3】:

对于那些将来发现这个问题的人,我想补充一点,你应该仔细检查你是如何启动 powershell 的。我遇到了同样的错误,并且无法弄清楚为什么解决方案都参考了使用 64 位版本,而我以为我已经这样做了。

事实证明,因为我使用第三方 32 位启动器运行 powershell,所以尽管是从 system32 文件夹启动的,但 powershell 还是回退到了 32 位可执行文件。感谢 x0n 提供了确认我正在使用的版本的方法,因为这引导我找到了我的解决方案。

【讨论】:

    【解决方案4】:

    使用以下命令打开 powershell 解决了我的问题:

    %SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe 
    

    只需使用上述命令调用 powershell 64 位版本,并将带有参数的脚本路径传递给它。

    【讨论】:

      【解决方案5】:

      只是为了连接点。 “urig”在另一个话题中回答了他自己的问题: TFS Power Tools 2008 Powershell Snapin won't run in on 64-bit in 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"="这是一个 PowerShell 管理单元包括 Team Foundation Server cmdlet。” "VendorIndirect"="Microsoft.TeamFoundation.PowerShell,Microsoft" "DescriptionIndirect"="Microsoft.TeamFoundation.PowerShell,这是一个包含 Team Foundation Server cmdlet 的 PowerShell 管理单元。" "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"

      【讨论】:

      • 不,另一个问题的答案与这里无关。一是关于 TFS powershell 管理单元在 x64 下不工作;这是关于 IIS 模块在 x86 下无法作为 WOW64 工作的问题。容易混淆,但不会。
      猜你喜欢
      • 1970-01-01
      • 2015-06-16
      • 2013-02-22
      • 2017-01-03
      • 2011-03-04
      • 1970-01-01
      • 1970-01-01
      • 2015-12-12
      相关资源
      最近更新 更多