【问题标题】:How can you change an IIS Site's App Pool with the Powershell Web Admin Commandlets如何使用 Powershell Web Admin Commandlets 更改 IIS 站点的应用程序池
【发布时间】:2011-06-05 12:15:28
【问题描述】:

以下代码演示了我认为可行的方法,但它不会更改应用程序池 - 它仍设置为当前值(即使 $site 对象确实更新了):

import-module WebAdministration

$site = get-item "IIS:\Sites\Project"
$site.ApplicationPool = "ProjectAppPool"
$site | set-item

如果您使用指定 -ApplicationPool 参数的 New-WebSite 创建站点,它将按预期创建。我必须使用什么 Powershell IIS web 命令来将现有站点的应用程序池更改为不同的东西?

【问题讨论】:

    标签: iis powershell


    【解决方案1】:

    ApplicationPool 是网站上 IIS: 驱动器中的一个属性。设置如下:

    #site level
    Set-ItemProperty 'IIS:\Sites\Default Web Site' applicationPool ProjectAppPool
    
    #app level
    Set-ItemProperty 'IIS:\Sites\Default Web Site\AppName' applicationPool ProjectAppPool
    

    如果您安装了PowerShell Community Extensions,您可以使用 Show-Tree 命令来探索这些驱动器,例如:

    Show-Tree IIS:\Sites -ShowProperty -Depth 1
    

    【讨论】:

    • 我发现“应用程序池”属性区分大小写,您需要将应用程序池更改为应用程序池。例如Set-ItemProperty 'IIS:\Sites\Default Web Site\AppName' applicationPool ProjectAppPool
    • Get-ItemPropertySet-ItemProperty命令可用之前需要Import-Module WebAdministration
    猜你喜欢
    • 2021-10-14
    • 2016-04-24
    • 1970-01-01
    • 2012-12-23
    • 2017-01-06
    • 1970-01-01
    • 2014-09-25
    • 2010-09-20
    • 1970-01-01
    相关资源
    最近更新 更多