Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rename application pool that already has application assigned to it?

I have an Application pool that has a lot of applications been assigned to it, it won't let me rename.

Beside delete and creating a new application pool, is there anyway to get a new name for my application pool? I don't want to go and reassign every application in it.

like image 483
J - C Sharper Avatar asked Oct 29 '13 23:10

J - C Sharper


People also ask

How do I change the application pool on my website?

In the General section of the Advanced Settings dialog box, click the Application Pool entry, and then click the ellipses button. In the Select Application Pool dialog box, select the application pool from the Application pool: drop-down box, click OK, and then click OK again.

How do I remove an app from application pool?

1. In the View List under Server Configuration, click Internet Information Services. 2. In the Application Pools explorer, right-click the application pool and click Delete.


2 Answers

Assign applications to another pool, rename the one you wanted renamed. Re-assign applications back to your pool.

IIS doesn't support other options

like image 118
evhen14 Avatar answered Sep 19 '22 07:09

evhen14


This was the simplest way that I could work it out, although I can't believe this isn't easier.

Import-Module WebAdministration

$oldName = "OldAppPool";
$newName = "NewAppPool";

if(-not (Test-Path IIS:\AppPools\TempPool)){
    New-WebAppPool TempPool
}
$tempAppPool = Get-Item IIS:\AppPools\TempPool

foreach($site in Get-ChildItem IIS:\Sites){
    $apps = $site | Get-ChildItem | Where-Object { $_.ApplicationPool -eq $oldName }

    foreach($app in $apps){
        $path = ("IIS:\Sites\{0}\{1}" -f $site.name, $app.name)
        $path
        Set-ItemProperty $path applicationPool TempPool
    }
}

Set-ItemProperty "IIS:\AppPools\$oldName" -Name name -Value $newName

foreach($site in Get-ChildItem IIS:\Sites){
    $apps = $site | Get-ChildItem | Where-Object { $_.ApplicationPool -eq "TempPool" }

    foreach($app in $apps){
        $path = ("IIS:\Sites\{0}\{1}" -f $site.name, $app.name)
        $path
        Set-ItemProperty $path applicationPool $newName
    }
}

Remove-WebAppPool TempPool
like image 22
Alexis Coles Avatar answered Sep 22 '22 07:09

Alexis Coles