0
votes

I'm running a W2K8 R2 Web server with multiple applications in each app pool. I had to move some sites from one app pool to another, so I ran this script:

Import-Module WebAdministration
Get-Content C:\Applications.txt | Foreach-Object {Set-ItemProperty –Path “IIS:\Sites\Default Web Site\$_" ApplicationPool –Value Pool02}

The result was that the applications changed as viewed in the GUI. When I right click the pool for a list it's been correctly moved. However, when I drill into the advanced settings of the application itself, the Application Pool value hasn't changed and it's actually still running in the old pool and using memory even though it doesn't show that in the GUI.

Any ideas?

1
You might have to recycle your pools through Restart-WebAppPoolDavid Brabant

1 Answers

0
votes

If you have an App in the destination pool already you can do something like this:

Import-Module WebAdministration
Get-Content C:\Applications.txt | Foreach-Object {
    $DestAppPool = (Get-SPWebApplication <any app in the desired destination pool>).ApplicationPool
    $WebApp = Get-SPWebApplication "IIS:\Sites\Default Web Site\$_"
    $WebApp.ApplicationPool = $DestAppPool
    $WebApp.ProvisionGlobally()
    $WebApp.Update()
}
iisreset