Windows PowerShell Snap-In for IIS not working on 32-bit?

I am trying to write a PowerShell script that automates the deployment of my IIS site. I am trying to run scripts on my computer running Windows Server 2008 R2 under 32-bit versions:

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

Whenever I run the WebAdministration command, for example:

Get-Website -Name "MYWebsite"

I get an error message:

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 fixes this problem, but it also makes it impossible to use Microsoft Team Foundation Server 2008 Power Tools PSSnapin, which is not suitable for me.

Any idea how I can overcome this? Thanks in advance.

+3
source share
4 answers

. "urig" : TFS Power Tools 2008 Powershell Snapin 64- Windows 2008 R2

" Microsoft , . 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" "" = "Microsoft Corporation" "" = " PowerShell, Team Foundation Server." "VendorIndirect" = "Microsoft.TeamFoundation.PowerShell, Microsoft" "DescriptionIndirect" = "Microsoft.TeamFoundation.PowerShell, PowerShell, Team Foundation Server". "" = "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 \Microsoft.TeamFoundation.PowerTools.PowerShell.dll" "CustomPSSnapInType" = "Microsoft.TeamFoundation.PowerTools.PowerShell.TFPSSnapIn"

-1

:

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

32 ; -)

, . system32, 64- . , .

:

ps> [intptr]::size
4

4, 32 . 64- powershell 8.

-Oisin

+4

, , - 64- PowerShell, Oisin, Start-Job -RunAs32 script, snapin TFS PowerTools TFS. , . 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
+2

, , , , PowerShell. , 64- , , .

It turns out that since I started powershell with a 32-bit third-party launch, PowerShell returned to the 32-bit executable, despite the fact that it was launched from the system32 folder. Thanks to x0n for the version confirmation method I used, this led me to my decision.

+1
source

Source: https://habr.com/ru/post/1760039/


All Articles