Reputation: 81
I'm writing up a script to create a new app pool if an app pool I'm passing in does not exist. When the pool is created and I run Get-IISAppPool in the same session, the new app pool does not exist.
Here's how to duplicate it.
New-WebAppPool -Name "Test"
Get-IISAppPool
It will not show the new one that was created.
If you open up a new shell and run Get-IISAppPool, you'll see the new app pool.
Any thoughts on how to overcome this?
Upvotes: 5
Views: 2551
Reputation: 25031
For better or for worse, I was able to reliably see the new app pool consistently this way:
New-WebAppPool -Name "Test"
Reset-IISServerManager
Get-IISAppPool
This seems like a weird bug. As a workaround, you could also do the following if you don't need the output types to be Microsoft.Web.Administration.ApplicationPool
import-module WebAdministration # this is only necessary if you don't execute WebAdministration module cmdlets before the GCI command
New-WebAppPool -Name "Test"
get-childitem IIS:\AppPools
Upvotes: 12