0

Is it possible to add a site (and bindings) to my applicationHost.config file for IIS Express or IIS ?

here's one I had to manually add (which works perfectly) ...

<site name="Our Awesome website" id="4">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="C:\Projects\XWing\Code\Application\Website" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:1200:localhost" />
        <binding protocol="http" bindingInformation="*:80:localhost.www.mywebsite.com.au" />
        <binding protocol="https" bindingInformation="*:44302:localhost.www.mywebsite.com.au" />
        <binding protocol="http" bindingInformation="*:80:localhost.www.mywebsite2.com" />
        <binding protocol="https" bindingInformation="*:44302:localhost.www.mywebsite2.com" />

/>

Is this possible? (i'm assuming the <site>..</site> does not exist)

Pure.Krome
  • 6,338
  • 17
  • 72
  • 86
  • To the person who thinks this is not relevant to prof ITOps, please suggest another SE sister site, instead of just downvoting. please :) – Pure.Krome Dec 08 '14 at 10:20
  • Here's how I did it http://stanbashtavenko.com/managing-iisexpress-with-powershell/ There is a link to complete script at the bottom – Stan Bashtavenko Jul 02 '15 at 20:13

1 Answers1

1

The New-Website and New-WebBinding[2] applets should do what you are asking.


1: http://technet.microsoft.com/en-us/library/ee790605.aspx
2: http://technet.microsoft.com/en-us/library/ee790567.aspx

DTK
  • 1,688
  • 10
  • 15
  • Can I use these to *check* if a website exists (eg. -> if "Our Awesome website" doesn't exist .. then `New-Website`....) – Pure.Krome Dec 08 '14 at 04:49
  • You would use Get-Website applet – DTK Dec 08 '14 at 04:55
  • And finally - two more questions please :) 1) Can this be used against the *IIS express* (not just IIS) .. and 2) if the site doesn't exist, `Get-Website` throws an error message? how to avoid the error? (basically, i'm trying to do -> `$result = Get-Website -Name "Our Awesome website"; if (-Not $result) { add .. } else { .. do nothing }` – Pure.Krome Dec 08 '14 at 05:04
  • I don't know from IIS Express, so I couldn't tell you. You could make $results an array and suck in all of the entries in Get-WebSite. Then if ($results -contains "Our Awesome website) {Write-Output "Found it"} else { Do-TheNeedful -onceMore -withFeeling } – DTK Dec 08 '14 at 12:34