Cannot create IIS application pool from powershell script

rklingelheberrklingelheber Posts: 4
edited January 18, 2013 12:37PM in Deployment Manager
I'm trying to create a deploy.ps1 script that will create an IIS application pool and configure it. The script works as expected when run from a powershell prompt, but fails with the following error when executed from a DM deployment:
2013-01-08 19:27:27 DEBUG ERROR: Test-Path : 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 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
ERROR: At C:\ProgramData\Red Gate\DeploymentAgent\Applications\Test\MyPackage\1.0.3_1\deploy.ps1:15 char:16
ERROR: + if ( (test-path <<<< -path $virtual) -eq $True )
ERROR: + CategoryInfo : InvalidArgument: (:) [Test-Path], ParameterBindingException
ERROR: + FullyQualifiedErrorId : GetDynamicParametersException,Microsoft.PowerShell.Commands.TestPathCommand

Here is the script:
import-module WebAdministration

$apppool = "iis:\apppools\Sample"
if &#40; &#40;test-path -path $apppool&#41; -eq $False &#41;
	write-host "creating apppool"
	new-item $apppool

Also note that I have changed the DM agent to run as an administrator on the machine.



  • Hi

    My initial thought is that this is due to the difference in bitness i.e. the bitness (64 bit/32 bit) of powershell prompt is different to the bitness of the agent.

    The deployment agent used to be 64 bit, it has now become 32 bit. So the bitness of the agent depends on which version of the agent you have installed. (It can be checked by running Task Manager).

    I should also mention that someone on StackOverflow dealt with a similar problem: ... pplication.

    In order to help you further, would you please confirm if the bitness is in fact different for the two places that you are running the script? If that is the case, what is the bitness of your agent and the platform where you run it on powershell prompt?

    Chirayu Shishodiya
    Software Engineer - Deployment Manager
    Red Gate
  • I believe you are correct about the Powershell bitness. If I run the script in a 32 bit PS prompt it fails. If I run the script in a 64 bit PS prompt it succeeds. I was unknowingly launching a 64 bit prompt when I selected "Import system modules" from the PS shortcut context menu.

    I verified that the DM agent is running as a 32 bit app. DM server is 64 bit.

    I would like to be able to manipulate IIS from Powershell deployment scripts if possible. Is there a way to tell the agent to host Powershell as a 64 bit host? If not, is there a work-around for this issue?

    Thank you.
  • Brian DonahueBrian Donahue Posts: 6,590 New member
    I found this... ... ssues.aspx

    Basically it says to ditch the WebAdministration module and use Microsoft.Web.Administration.
  • @rklingelheber: How are you getting on with Deployment Manager? Did you manage to solve the problem using Microsoft.Web.Administration module?
    Chirayu Shishodiya
    Software Engineer - Deployment Manager
    Red Gate
  • I tried to use the Microsoft.Web.Administration module, but it was modifying IIS Express instead of IIS on my development box.

    There may be a way to get that to work, but I gave up on it for now and am exe-ing out to our old NAnt scripts just to prove automated deployment concept to folks in the office.

    I think that if Powershell is the core scripting mechanism for DM, that it should support the Powershell IIS commandlets without work arounds. For folks that are deploying web apps and services, they are going to want a lot of control around this area - and it shouldn't be hard.
Sign In or Register to comment.