我需要一个 Powershell 命令,其作用相当于在 IIS 中添加网站,但需要“应用程序池”的绑定(bind):
到目前为止,我可以添加一个网站来执行此操作:
New-Item iis:\Sites\swmarket -bindings @{protocol="http";bindingInformation="80:swmarket"} -physicalPath c:\inetpub\wwwroot
但我不知道如何在新网站中设置“应用程序池”。有什么办法可以查看所有绑定(bind)吗?
最佳答案
Set-ItemProperty iis:\Sites\swmarket -Name applicationpool -Value swmarket
或者,使用 Powershell 3,您可以执行以下操作:
New-WebAppPool -Name $WebSiteName
New-Website -Name $WebSiteName -ApplicationPool $WebSiteName -HostHeader $WebSiteName -PhysicalPath $PathInfo -Port 80
Set-Content $PathInfo\default.htm “PSCreated Default Page”
查看 MS Technet 描述 here.
关于iis - 使用 Powershell 在 IIS 中设置网站的应用程序池,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14238270/