PowerShell and IIS Assistance


Continuing on my PowerShell learning experience...

I am trying to create an Application Pool in IIS and set some settings. I can create the pool ok but am unable to actually set the settings. Here is what I have:

Import-Module WebAdministration

cd IIS:\AppPools
$appPool = New-Item "My New App Pool"
$appPool.managedPipelineMode = "Classic"
$appPool.managedRuntimeVersion = "v4.0"
$appPool.enable32BitAppOnWin64 = "True"

My issue is the pool gets created but none of the settings stick. I do not see anything like an $appPool.Save, etc.

How do I get the items I am setting to stick?

Thanks, Charles
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dan McFaddenSystems EngineerCommented:
After creating the new AppPool, you could pull the default configuration into an object:

$ThisAppPool = Get-Item IIS:\AppPools\MyNewAppPool

Open in new window

Now you can use "Set-ItemProperty" to update the configuration properties that you want to.

Set-ItemProperty IIS:\AppPools\MyNewAppPool -Name queueLength -Value 500

Open in new window

Here is a good reference on the subject.

link: http://www.iis.net/learn/manage/powershell/powershell-snap-in-making-simple-configuration-changes-to-web-sites-and-application-pools


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ckelsoeAuthor Commented:
Thanks much. That works. The one part of PowerShell that is messing me up is that there are 15 ways to do something syntax wise and it seems random as to what works where.
ckelsoeAuthor Commented:
Now I am having an issue setting a sub application application pool.

Here is what I have tried.

Set-Location IIS:\Sites\Default Web Site\MySubSite
Set-ItemProperty -Name applicationPool - Value 'My New Pool'

When I do that I get prompted for path[0]. I can put in IIS:\Sites\Default Web Site\MySubSite but I want to be able to do this without the secondary prompts.

What am I missing?
Dan McFaddenSystems EngineerCommented:
I would just try this command:

Set-ItemProperty 'IIS:\Sites\Default Web Site\MySubSite' -Name ApplicationPool -Value MySubSiteAppPool

Open in new window

Assuming that you are talking about a Virtual Application that is a child object of the default site.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.