Create IIS Website using Powershell

#Script template

function createIISWebsite($siteName,$sitePath,$siteUrl) {

$siteName = Get-IISSite

$sitePath =

$siteUrl =

return … }

Create IIS Website

:black_small_square: Description:

  • Create new IIS http website in port 80
  • If the site name already exists, update the existing using new input parameter
  • Show error when some problem happens, i.e., path not found

:black_small_square: Script name: createIISWebsite

:black_small_square: Input:

  • siteName
  • sitePath
  • siteUrl

:black_small_square: Output: status of IIS website creation

:black_small_square: Sample input:

  • siteName: test local
  • sitePath: “D:\Test”
  • siteUrl: test.localhost

:black_small_square: Sample output:

  • if success = " successfully created, you can access it via "
  • if site name already exist = " already exist, updated the site path to and you can

access it via "

if problem happen = "Error: "

o Description

  • Can specify the port (not only port 80)
  • Can specify site type: http or https
  • Input parameter and output is up to you

It’s my first time scripting in powershell, i really need help

Google is your friend :slight_smile: Put together a script then post for input from the forum.