我正在尝试使用 Powershell WebAdministration 模块复制现有的 IIS 7.5 应用程序池,而无需停止应用程序。
当我复制应用程序池时,应用程序正在运行并加载,我收到 NullReferenceException。
$pool = 'app1-0'
$newpool = 'app1-1'
cp "iis:/apppools/$pool" "iis:/apppools/$newpool" -force
输出:
Copy-Item : Object reference not set to an instance of an object.
如果我停止池,或启动应用程序池但不加载应用程序,则复制命令成功。
没有一个一个地复制属性,有没有办法复制/克隆一个正在运行和加载的应用程序池?
最佳答案
您是否尝试过使用 appcmd 代替?
更新:尝试两者的组合 -
也许 add 不允许您同时导入和指定命令。你可以尝试这样的事情:
appcmd list appool thing1 /xml > c:\tempfile.xml
(Get-Content c:\tempfile.xml).Replace("thing1", "thing2") | Out-File c:\tempfile2.xml
appcmd add apppool /in < c:\tempfile2.xml
您可能需要稍微调试一下该脚本:)
关于powershell - 使用 Powershell WebAdministration 复制正在运行的 IIS 应用程序池,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7879820/