Created
February 26, 2014 15:31
-
-
Save ifrahim/9231677 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
# 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 |
@margani I think you'll find it is stopped by default. (At least mine was.)
How to edit config Application Pool
existed in IIS using Powershell ? thanks.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you. How can you create a new website but in stopped state?