2

I'm writing a small web application that will run some powershell scripts on the localhost to create new IIS sites etc. I have the script working fine in ISE 64 bit but when trying to run them in 32 bit I'm getting errors like:

Get-ChildItem IIS:\Sites
Get-ChildItem : Cannot retrieve the dynamic parameters for the cmdlet. Retrieving the COM class factory for component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: 80040154.

I've tried downloading the x86 version of the snap-in but the installer stops telling me to use 'Programs and Features' to install it which I've tried but cant find what's not enabled that should be.

This is an issue as the .NET application seems to run the scripts in the 32 bit powershell so my 2 questions are:

  1. Can I run these scripts in 64 bit from .NET
  2. Can I install these snap ins in 32 bit on a 64 bit OS
dmgdotnet
  • 363
  • 2
  • 12
  • still haven't found a solution to this unfortunately although the project has been put on hold for now – dmgdotnet May 31 '12 at 21:53
  • Depending on the windows server OS, the **WebAdministration** module/snapin may not be present. See [related SO post](http://stackoverflow.com/a/30512464/175679). – SliverNinja - MSFT May 28 '15 at 16:47

1 Answers1

1

PowerShell installs both the 32-bit and 64-bit WebAdministration modules. When you create your runspace, are you executing Import-Module WebAdministration before attempting to use the IIS: drive (provider)?

Keith Hill
  • 194,368
  • 42
  • 353
  • 369
  • 1
    Yeah I'm running the same script in Powershell 32 and 64. If I just use a simple script like the following: import-module WebAdministration; Get-Website | Where {$_.Name -eq "ExampleSite"} I get: Get-Website : Retrieving the COM class factory for component.... Works fine in 64 bit powershell – dmgdotnet Nov 06 '11 at 03:08
  • Are you running as admin (elevated if on Vista/Win7 with UAC enabled). In C# exe, what apartment is Main decorated with (STA or MTA)? Also try setting your app's Platform Target to x64 and see if it works on yrou x64 system. If that works and you need to support both x86 and x64, try setting the Platform Target to AnyCPU. BTW other folks have run into this issue. See http://forums.iis.net/t/1163290.aspx. – Keith Hill Nov 06 '11 at 05:37