Red Gate forums :: View topic - Cannot create IIS application pool from powershell script
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
Deployment Manager
Deployment Manager forum

Cannot create IIS application pool from powershell script

Search in Deployment Manager forum
Post new topic   Reply to topic
Jump to:  
Author Message
rklingelheber



Joined: 08 Jan 2013
Posts: 3

PostPosted: Tue Jan 08, 2013 8:45 pm    Post subject: Cannot create IIS application pool from powershell script Reply with quote

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:

Quote:
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: (Smile [Test-Path], ParameterBindingException
ERROR: + FullyQualifiedErrorId : GetDynamicParametersException,Microsoft.PowerShell.Commands.TestPathCommand


Here is the script:
Code:

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!
Back to top
View user's profile Send private message
chirayu



Joined: 17 Sep 2012
Posts: 65

PostPosted: Thu Jan 10, 2013 11:48 am    Post subject: Reply with quote

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/6866150/powershell-new-webapplication.

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
Back to top
View user's profile Send private message
rklingelheber



Joined: 08 Jan 2013
Posts: 3

PostPosted: Thu Jan 10, 2013 5:53 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6678

PostPosted: Fri Jan 11, 2013 3:59 pm    Post subject: Reply with quote

I found this...
http://www.mattwrock.com/post/2011/01/04/Nuget-and-Powershell-WebAdministration-Module-Issues.aspx

Basically it says to ditch the WebAdministration module and use Microsoft.Web.Administration.
Back to top
View user's profile Send private message
chirayu



Joined: 17 Sep 2012
Posts: 65

PostPosted: Fri Jan 18, 2013 4:17 pm    Post subject: Reply with quote

@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
Back to top
View user's profile Send private message
rklingelheber



Joined: 08 Jan 2013
Posts: 3

PostPosted: Fri Jan 18, 2013 6:37 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group