IIS: Updating the App Pool for an Application

I have been working on a script to map IIS Sites to a different App Pool.

This works when the object is a Site:

Set-ItemProperty -Path "IIS:\Sites\Sitename" -Name ApplicationPool -Value "NewPool"

However, if the object is an Application under a Site, this runs without an error, but the value does not change.
I’ve tried using a “Set-Item” on the Application object, but that errors out.

Any ideas?


use the appcmd command

appcmd set app /app.name: string /applicationPool: string


I have also seen on other sites where it is stated that “applicationPool” appears to be case sensitive.

so instead of doing

Set-ItemProperty -Path "IIS:\Sites\Sitename\app" -Name ApplicationPool -Value "NewPool"


Set-ItemProperty -Path "IIS:\Sites\Sitename\app" -Name applicationPool -Value "NewPool"

Thanks for the help Curtis. The second option, changing he case, doesn’t appear to work.

The appcmd option works. However, I have run in to a problem with it - it requires the powershell session to be run as administrator.

Any suggestions how I can do that using a remote Invoke-Command?