如何重命名已分配应用程序的应用程序池?

J -*_*per 14 iis application-pool

我有一个应用程序池,它已经分配了很多应用程序,它不会让我重命名.

除了删除和创建新的应用程序池之外,还有为我的应用程序池获取新名称吗?我不想去重新分配其中的每个应用程序.

evh*_*n14 14

将应用程序分配给另一个池,重命名您想要重命名的池.将应用程序重新分配回池中.

IIS不支持其他选项


Ale*_*les 5

这是我能解决的最简单的方法,尽管我不敢相信这并不容易。

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
Run Code Online (Sandbox Code Playgroud)