Cannot create IIS application pool from powershell script
rklingelheber
Posts: 4
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:
Here is the script:
Also note that I have changed the DM agent to run as an administrator on the machine.
Thanks!
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 ( (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!
Comments
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!
Software Engineer - Deployment Manager
Red Gate
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.
http://www.mattwrock.com/post/2011/01/0 ... ssues.aspx
Basically it says to ditch the WebAdministration module and use Microsoft.Web.Administration.
Software Engineer - Deployment Manager
Red Gate
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.