Created
May 16, 2017 12:47
-
-
Save deejaygraham/4cf60360ef1abca6245d5701bbb33aab to your computer and use it in GitHub Desktop.
Create a very basic, static website in IIS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module WebAdministration | |
[string]$IISAppPoolName = "my-lovely-site" | |
[string]$IISAppPoolDotNetVersion = "v4.0" | |
[string]$IISAppName = "MyLovelySite" | |
[int]$Port = 3000 | |
[string]$ScriptFile = $MyInvocation.MyCommand.Path | |
[string]$ScriptFolder = Split-Path $ScriptFile -Parent | |
[string]$DirectoryPath = Join-Path $ScriptFolder -ChildPath html | |
cd IIS:\AppPools\ | |
If (Test-Path $IISAppPoolName -PathType container) { | |
Remove-WebAppPool $IISAppPoolName | |
} | |
$AppPool = New-Item $IISAppPoolName | |
$AppPool.managedRuntimeVersion = $IISAppPoolDotNetVersion | |
cd IIS:\Sites\ | |
If (Test-Path $IISAppName -PathType Container) { | |
Remove-Website $IISAppName | |
} | |
New-Website -Name $IISAppName -PhysicalPath $DirectoryPath -ApplicationPool $AppPool.name -Port $Port | Out-Null | |
Start-Process -FilePath "http://localhost:$Port/index.html" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment