8

I need a Powershell command that does the equivalent of adding a website in IIS, but need the bindings for the "Application pool":

enter image description here

So far I can add a website doing this:

New-Item iis:\Sites\swmarket -bindings @{protocol="http";bindingInformation="80:swmarket"} -physicalPath c:\inetpub\wwwroot

But I don't know how to set the "Application pool" in the new website. Any way to see all the bindings?

D3vtr0n
  • 2,774
  • 3
  • 33
  • 53
Kasper Hansen
  • 6,307
  • 21
  • 70
  • 106

1 Answers1

12
Set-ItemProperty iis:\Sites\swmarket -Name applicationpool -Value swmarket

Alternatively, with Powershell 3, you could do this:

New-WebAppPool -Name $WebSiteName
New-Website -Name $WebSiteName -ApplicationPool $WebSiteName -HostHeader $WebSiteName -PhysicalPath $PathInfo -Port 80
Set-Content $PathInfo\default.htm “PSCreated Default Page”

Check out the MS Technet description here.

D3vtr0n
  • 2,774
  • 3
  • 33
  • 53
  • Looks like it is case-sensitive. Should be applicationPool, not applicationpool. – EdH Nov 14 '22 at 21:12