HOW TO CREATE A APPLICATION POOL CODE
Simply specify the name and it’s gone!Īll of this code we’ve been using was all executed locally, but what if you need to run it on a remote IIS server? This is where PowerShell remoting comes in. This time we have a built-in PowerShell cmdlet called Remove-WebAppPool. Set-ItemProperty -Path IIS:AppPoolsMyAppPool -Name managedRuntimeVersion -Value ‘v4.0’īy using Set-ItemProperty you can modify nearly all of the properties for an app pool.įinally, we’re done with our app pool and now need to remove it. Again using the IIS drive we can use Set-ItemProperty to manage app pools like we can the file system, registry, certificates and all the other things that have a PowerShell drive.
Now that you’ve got an app pool and can see the properties, let’s modify a property. Get-ItemProperty IIS:AppPoolsMyAppPool | select * This will return all of the property names and values so you can figure out which ones you need to modify with Set-ItemProperty.
We can then check all of the properties on that app pool using Get-ItemProperty and select all of the properties it returns with Select-Object. Simply use New-Item and specify the path. Using the IIS drive makes this very easy. It looks like we have one called GHI already maybe we want to create another one. Let’s first check to see if any app pools already exist. This is where most of the app pool configuration will be done. This brings in all of the IIS cmdlets, and creates the IIS drive. To manage application pools, we’ll first need to import the WebAdministration module. We’ll then use Invoke-Command to execute this scriptblock on the remote IIS server. NOTE: Going forward, we’ll be building code to input into a scriptblock. It can be pretty frustrating the first time you try this as you won’t see that familiar –ComputerName parameter on many of the cmdlets. Although that’s not a deal-breaker, it does make the code a little more verbose than what it could be. In order to manage IIS servers remotely, we’re forced to use PowerShell remoting with the Invoke-Command cmdlet.
If you’ve never used PowerShell to manage your IIS servers before your first inclination might be to look for a –ComputerName on most of the cmdlets. Where do you turn when you’re managing an IIS web server farm with potentially dozens or hundreds of app pools? PowerShell, of course.īy using the WebAdministration PowerShell module that comes installed as part of IIS and a little PowerShell remoting you can easily create, modify and remove app pools at will.