Author Posts

August 28, 2017 at 8:41 pm

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?

Thanks,
Des

August 28, 2017 at 8:57 pm

use the appcmd command

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

https://technet.microsoft.com/en-us/library/cc731755(v=ws.10).aspx

August 28, 2017 at 9:06 pm

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"

do

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

August 29, 2017 at 9:18 pm

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?