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

2016-05-04_15-55-11

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:

2016-05-04_16-15-28

The command in question will look like this for file:

2016-05-04_16-29-58

Creating Web-Sites

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

2016-05-04_16-40-53

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.

2016-05-04_16-47-57

2016-05-04_16-47-13

Creating Web Applications

Specifying the -type parameter you tells the create an application

2016-05-04_17-07-14

2016-05-04_17-09-57

List Sites

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

2016-05-04_23-29-17

This is another way to list them

2016-05-04_23-36-03

Deleting Sites

Here is how you delete the site using powershell.

2016-05-04_17-12-24

2016-05-04_17-13-58