Skip to content

Instantly share code, notes, and snippets.

@JoshuaCarroll
Forked from ifrahim/CreateIISSite
Last active July 25, 2018 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoshuaCarroll/addfb2eaea86612801ef6db59e1b6533 to your computer and use it in GitHub Desktop.
Save JoshuaCarroll/addfb2eaea86612801ef6db59e1b6533 to your computer and use it in GitHub Desktop.
Create IIS Site using Powershell
# 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
Function createIISWebsite {
Param ([string]$Folder, [string]$AppPoolName, [string]$SiteName, [string]$Port)
import-module webadministration
New-Item $Folder -type Directory
Set-Content $Folder\Default.htm "<h1>Hello IIS</h1>"
New-Item IIS:\AppPools\$AppPoolName
New-Item IIS:\Sites\$SiteName -physicalPath $Folder -bindings @{protocol="http";bindingInformation=":" + $Port + ":"}
Set-ItemProperty IIS:\Sites\$SiteName -name applicationPool -value $AppPoolName
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment