-
-
Save dejanstojanovic/dffb8ff8c8edc37bc2ccfac1fc52243c to your computer and use it in GitHub Desktop.
Create IIS Site using Powershell
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
#unzip -> https://stackoverflow.com/questions/27768303/how-to-unzip-a-file-in-powershell | |
#check -> http://geekswithblogs.net/QuandaryPhase/archive/2013/02/24/create-iis-app-pool-and-site-with-windows-powershell.aspx | |
#check -> https://docs.microsoft.com/en-us/iis/manage/powershell/powershell-snap-in-creating-web-sites-web-applications-virtual-directories-and-application-pools | |
# The following code will create an IIS site and it associated Application Pool. | |
# Please note that you will be required to run PS with elevated permissions. | |
# Visit http://ifrahimblog.wordpress.com/2014/02/26/run-powershell-elevated-permissions-import-iis-module/ | |
# set-executionpolicy unrestricted | |
$SiteFolderPath = "C:\WebSite" # Website Folder | |
$SiteAppPool = "MyAppPool" # Application Pool Name | |
$SiteName = "MySite" # IIS Site Name | |
$SiteHostName = "www.MySite.com" # Host Header | |
New-Item $SiteFolderPath -type Directory | |
Set-Content $SiteFolderPath\Default.htm "<h1>Hello IIS</h1>" | |
New-Item IIS:\AppPools\$SiteAppPool | |
New-Item IIS:\Sites\$SiteName -physicalPath $SiteFolderPath -bindings @{protocol="http";bindingInformation=":80:"+$SiteHostName} | |
Set-ItemProperty IIS:\Sites\$SiteName -name applicationPool -value $SiteAppPool | |
# Complete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment