iis - 使用 Powershell 在 IIS 中设置网站的应用程序池

标签 iis powershell application-pool

我需要一个 Powershell 命令,其作用相当于在 IIS 中添加网站,但需要“应用程序池”的绑定(bind):

enter image description here

到目前为止,我可以添加一个网站来执行此操作:

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/

相关文章:

IIS 无法找到 web.config

python-3.x - 如何修复 : ERR Protocol error: expected '$' , 得到 ' '

powershell - 为什么PS脚本可在ISE中工作但不能在SQL Server 2012中工作

powershell - PSCustomObject 不喜欢 NoteProperty 值中的内联 if 语句

asp.net - 如何加快 ASP.NET 应用程序的重新启动速度?

c# - 使用 Windows 身份验证的 ASP.Net Core 3.1 中的空闲超时

asp.net - CSS 和 JS 文件加载

c# - session 变量由于某种原因丢失

c# - 获取网站服务的 tcp 端口

visual-studio - 如何通过VS和MSDeploy设置控制用于部署的AppPool