powershell - 使用 Powershell WebAdministration 复制正在运行的 IIS 应用程序池

标签 powershell iis-7.5

我正在尝试使用 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/

相关文章:

c# - 性能分析 asp.net,什么是 ProcessRequestNotificationHelper?

asp.net - 为 URL 路由中的页面强制使用自定义 404 页面

powershell - 如何为Set-Content调用提供唯一的凭据

powershell - 如何抑制写入控制台的 "What if"文本

powershell - 调用命令在同一行指定脚本 block

c# - 事件消息 : An unhandled access exception has occurred (IIS 7. 5,无法加载网站)

不带 .svc 扩展名的 WCF 端点地址

asp.net-mvc-3 - VSTS 错误序列化异常

regex - PowerShell 字符串匹配和管道字符

powershell - 遍历自定义对象中的每个NoteProperty