We can automate the create, modify, delete  websites in IIS using powershell scripts. I want to share some useful scripts help you save time.

Loading the Web Administration Module

The first step is to load in the powershell module for IIS


Creating a New File or Folder

New-Item is a quick and easy way to create a new file or folder on your computer. As an example, suppose you want to create a new directory named Windows PowerShell within the C:\Scripts folder. To do that call New-Item along with:

1) the full path to the new folder; and,

2) the new item type (which you can specify using the -type parameter and the value directory).

The command in question will look like this for directory:


The command in question will look like this for file:


Creating Web-Sites

New-Item is also used to create new Web-Sites within the IIS PowerShell, you can see Default Web Site below.


Powershell Command:  

When you create a Web-Site need some additional parameters like the file system path and network bindings are needed to create a Web-Site.



Creating Web Applications

Specifying the -type parameter you tells the create an application



List Sites

You can get a list of websites running on the server by using the Get-Website cmdlet or by running Get-ChildItem


This is another way to list them


Deleting Sites

Here is how you delete the site using powershell.