Cannot create IIS application pool from powershell script

Automated deployment for web applications and databases

Moderators: Mike Upton, justin.caldicott, Sean.newham, csmith, chirayu, DavidSimner, david.conlin

Cannot create IIS application pool from powershell script

Postby rklingelheber » Tue Jan 08, 2013 8:45 pm

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:
Code: Select all
import-module WebAdministration

$apppool = "iis:\\apppools\\Sample"
if ( (test-path -path $apppool) -eq $False )
{
   write-host "creating apppool"
   new-item $apppool
}


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

Thanks!
rklingelheber
 
Posts: 3
Joined: Tue Jan 08, 2013 8:16 pm

Postby chirayu » Thu Jan 10, 2013 11:48 am

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: http://stackoverflow.com/questions/6866 ... 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?

Thanks!
Chirayu Shishodiya
Software Engineer - Deployment Manager
Red Gate
chirayu
 
Posts: 65
Joined: Mon Sep 17, 2012 5:48 pm

Postby rklingelheber » Thu Jan 10, 2013 5:53 pm

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.
rklingelheber
 
Posts: 3
Joined: Tue Jan 08, 2013 8:16 pm

Postby Brian Donahue » Fri Jan 11, 2013 3:59 pm

I found this...
http://www.mattwrock.com/post/2011/01/0 ... ssues.aspx

Basically it says to ditch the WebAdministration module and use Microsoft.Web.Administration.
Brian Donahue
 
Posts: 6669
Joined: Mon Aug 23, 2004 10:48 am

Postby chirayu » Fri Jan 18, 2013 4:17 pm

@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
chirayu
 
Posts: 65
Joined: Mon Sep 17, 2012 5:48 pm

Postby rklingelheber » Fri Jan 18, 2013 6:37 pm

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.
rklingelheber
 
Posts: 3
Joined: Tue Jan 08, 2013 8:16 pm


Return to Deployment Manager

Who is online

Users browsing this forum: No registered users and 0 guests