---
title: "PowerShell IIS Mastery: Create and Manage Websites"
description: "Become an expert in managing IIS with PowerShell. Create websites, configure settings, and automate tasks to level up your IT skills."
canonical: "https://adamtheautomator.com/powershell-iis/"
---

# PowerShell IIS Mastery: Create and Manage Websites

> Become an expert in managing IIS with PowerShell. Create websites, configure settings, and automate tasks to level up your IT skills.

Source: https://adamtheautomator.com/powershell-iis/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![PowerShell IIS Mastery: Create and Manage Websites](https://adamtheautomator.com/wp-content/uploads/2019/12/microsoft-IIS-1280x720-1.png)

# PowerShell IIS Mastery: Create and Manage Websites

[![](https://secure.gravatar.com/avatar/4147968aa2332aa682bcebf295e4e9d0eb2672dee3d9ae0523a00ac51e7d6017?s=192&d=mm&r=g)Bill Kindle](https://adamtheautomator.com/author/bill/)3 December 201911 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[IIS](/tag/iis/)[PowerShell](/tag/powershell/)

Table of Contents

*   [IISAdministration vs WebAdministration Modules](#iisadministration-vs-webadministration-modules)
*   [Prerequisites](#prerequisites)
*   [Installing the IISAdministration Module](#installing-the-iisadministration-module)
*   [Discovering Available Cmdlets](#discovering-available-cmdlets)
*   [Creating Your First Website](#creating-your-first-website)
*   [Creating the Web Folder and Page](#creating-the-web-folder-and-page)
*   [Creating an IIS Website](#creating-an-iis-website)
*   [Managing the IIS Website](#managing-the-iis-website)
*   [Stopping a Single Site](#stopping-a-single-site)
*   [Stopping All Sites](#stopping-all-sites)
*   [Starting a Single Site](#starting-a-single-site)
*   [Starting All Sites](#starting-all-sites)
*   [Managing Web Bindings](#managing-web-bindings)
*   [Inspecting Existing Bindings](#inspecting-existing-bindings)
*   [Removing Bindings](#removing-bindings)
*   [Creating New Bindings](#creating-new-bindings)
*   [Removing a Website](#removing-a-website)
*   [Summary](#summary)
*   [Further Reading](#further-reading)

If you manage Windows Servers, you’ve likely worked with [Internet Information Services (IIS)](https://adamtheautomator.com/tag/iis/). Websites are one of IIS’s main features and, using PowerShell, you can easily manage and automate IIS with PowerShell IIS scripts!

Not a reader? Watch this related video tutorial!

**_Not seeing the video? Make sure your ad blocker is disabled._**

In this article, you’ll be introduced to a new way to manage IIS using PowerShell. Using the techniques in this article, you can easily build PowerShell IIS scripts to create and manage IIS websites.

To [manage IIS with PowerShell](https://adamtheautomator.com/powershell-scheduled-task/) requires one of two PowerShell modules – WebAdminstration or IISAdminstration. This article covers the more modern IISAdministration module. The companion video to this article demonstrates the older WebAdministration module if you’d like to see an alternative way.

Knowing how to manage even a simple website for your company or for the world at large will distinguish you from the rest of your peers. The following sections in this article will help you learn how to create and manage a website in IIS. You will also learn how to manage web application pools using a few PowerShell cmdlets.

If your goal is shipping a business website rather than managing every IIS detail yourself, compare [10Web for AI website building and managed WordPress hosting](https://10web.sjv.io/c/1454808/1979494/24269) before choosing a paid website platform.

## IISAdministration vs WebAdministration Modules

You have two options for managing IIS. You can use WebAdministration or IISAdministration. But which one should you use?

If you’re using IIS IIS 10.0 or higher, the newer IISAdministration module [offers a lot of improvements](https://docs.microsoft.com/en-us/iis/get-started/whats-new-in-iis-10/iisadministration-powershell-cmdlets) over the older WebAdministration module.

Here are a few highlights:

*   IISAdministration cmdlets offer better support for the pipeline and scale better.
*   Compared to the older, legacy IIS WebAdministration cmdlets, IISAdministration contains more efficient code.
*   IISAdministration cmdlets are simpler, and provide direct access to the server manager.

This article is going to focus on this newer IISAdministration module.

## Prerequisites

This article will be hands-on. If you intend to follow along, be sure you have the following prerequisites in place.

*   Minimum of Windows PowerShell 5.1 or PowerShell 6+
*   [IISAdministration PowerShell Module from the PowerShell Gallery](https://www.powershellgallery.com/packages/IISAdministration/1.1.0.0)
*   IIS 10.0 Windows Feature Enabled

![The Windows 10 "Turn Windows features on or off" dialogue](https://adamtheautomator.com/wp-content/uploads/2020/06/Untitled-42.png)

The Windows 10 “Turn Windows features on or off” dialogue

It’s recommended that you be familiar with basic of HTML. There will be a step that HTML use plays a role in the upcoming examples. But don’t worry, you will be able to copy and paste the code!

All examples in this blog post were created using IIS 10.0 on Windows 10 and PowerShell 7 Preview 6. The IISAdministration cmdlets are the same for Windows Server 2016 & 2019 and work with Windows PowerShell 5.1.

That’s it for the tools used, now for the resources needed to follow along.

## Installing the IISAdministration Module

Once you have met the prerequisites, it’s time for some setup work. Luckily, there’s not much setup to do since the [PowerShell module](https://adamtheautomator.com/powershell-modules/ "PowerShell module") you need (IISAdministration) is freely available in the PowerShell Gallery.

Go ahead and open up an elevated PowerShell console on your web server and install the module using the command below.

```powershell
PS> Install-Module -Name 'IISAdministration'
```

> _If you do not have internet access, you can download the module to another host and copy the module to your modules directory.  Take a look at the documentation for the [`Save-Module` command](https://docs.microsoft.com/en-us/powershell/module/powershellget/save-module)._

## Discovering Available Cmdlets

As with any PowerShell module that you may not be familiar with, one of the first cmdlets you should use to discover a modules cmdlet inventory is `Get-Command`. Using the command `Get-Command -Module 'IISAdministration'` as shown below will allow you to see what’s possible with this module.

Even though you’ll be learning some common actions to take on websites, these commands will give you an idea on everything else you can do.

![Get-Command -Module 'IISAdministration' results](https://adamtheautomator.com/wp-content/uploads/2020/06/Untitled-43-1-1024x691.png)

Get-Command -Module ‘IISAdministration’ results

Now you have a list of available cmdlets. It’s time to begin putting a site together.

## Creating Your First Website

To have a website to work with, let’s first create a website. To do that, the first step is to create a directory to save the web content. Additionally, you’ll need an HTML file in that directory for IIS to display. This directory will serve as the web directory that will be used in later examples.

### Creating the Web Folder and Page

First, create a directory. To do that, you can use the `New-Item` cmdlet. The code below will create a directory at _C:\\MyWebsite_.

```powershell
PS> New-Item -ItemType Directory -Name 'MyWebsite' -Path 'C:\'
```

> _You can choose whatever path you wish with the above code. To keep things simple, generic paths will be used._

Once you have created the directory, it’s time to create an HTML file that will be the landing page for your new website.

Now create a file called _index.html_ in the _C:\\Mywebsite_ directory as shown below.

```powershell
PS> New-Item -ItemType File -Name 'index.html' -Path 'C:\MyWebsite\'
```

Once the file is created, open it up in your favorite editor and copy and paste the code below into that document. This HTML is a simple page that will be used to ensure IIS is configured properly when you’re done.

```markup
<!DOCTYPE html>
<html>
    <head>
         <title>IIS Administration With PowerShell Demo</title>
    </head>
    <body>
        <h1>IIS Administration with PowerShell Demo</h1>
        <p>Thank you for reading this post on how to administer IIS with PowerShell!</p>

        <p>This page was created using the newer IISAdministration PowerShell module.</p>
        <h2>First Steps</h2>
        <p>Keep calm and learn PowerShell.</p>
    </body>
</html>
```

### Creating an IIS Website

It’s now time to make the webpage just created available for the world to see. To do that, you’ll need to create a _[virtual directory](https://docs.microsoft.com/en-us/iis/configuration/system.applicationhost/sites/site/application/virtualdirectory)._ The virtual directory contains all of the assets and resources used for the page being served.

> _By default, IIS creates a virtual directory under C:\\inetpub\\wwwroot. The directory contains all of the default webpage assets and resources for IIS. You could use the default C:\\inetpub\\wwwroot directory to store your files as well, but for these examples, it will not be used to keep the paths as short as possible. That’s why you are using C:\\MyWebsite instead._

To create a new virtual directory (site), use the [`New-IISSite` cmdlet](https://docs.microsoft.com/en-us/powershell/module/iisadministration/new-iissite). This cmdlet allows you to create the IIS website.

For this article, create a website called _Mywebsite_ pointed to the _C:\\MyWebsite_ directory that’s listening on port 8088. In the code snippet below, you can see how to do this using the `New-IISSite` cmdlet.

The only piece that might be confusing is the `BindingInformation` parameter. This parameter allows only [binding syntax](https://docs.microsoft.com/en-us/iis/configuration/system.applicationhost/sites/sitedefaults/bindings/binding). In this snippet, `New-IISSite` will create a website that is bound to an IP address (`*` is the same as 127.0.0.1), the TCP port to listen on followed by any HTTP headers.

_Binding syntax can be explained as protocol, followed by source:Port:destination . In this example, you’ve configured IIS to listen for HTTP requests from ANY (_) IP address on port 8088 and the destination is the localhost.\*

```powershell
PS> New-IISSite -Name 'MyWebsite' -PhysicalPath 'C:\MyWebsite\' -BindingInformation "*:8088:"
```

Once the site has been created, you can run `Get-IISSite` to inspect what it looks like as shown below.

![Creating a New Website in IIS](https://adamtheautomator.com/wp-content/uploads/2020/06/Untitled-44-1024x141.png)

Creating a New Website in IIS

By default, the website configuration is started and your web host begins serving those HTTP requests. Open your browser of choice and navigate to the local machine pointing to port 8088. You should now see the webpage you created earlier displayed.

![MyWebSite IIS site in a web browser](https://adamtheautomator.com/wp-content/uploads/2020/06/Untitled-45-1024x269.png)

MyWebSite IIS site in a web browser

Congratulations! You’ve just set up your first website on IIS using PowerShell!

Now that you have a website up and running, it’s time to learn how to manage your website and the IIS server hosting it.

## Managing the IIS Website

Once a website is up running, you will undoubtedly need to perform common actions like stopping and starting the site. For example, if the site needs updates made to it, you’ll sometimes have to restart the site.

To manage the site in PowerShell, you have two cmdlets to work with – [`Start-IISSite`](https://docs.microsoft.com/en-us/powershell/module/iisadministration/start-iissite) and [`Stop-IISSite`](https://docs.microsoft.com/en-us/powershell/module/iisadministration/stop-iissite). These two cmdlets work similarly to how the  `Stop-Service` and `Start-Service` cmdlets operate.

Stopping a website is similar to stopping a Windows service. You are preventing or allowing access to the site accessible by a protocol being served on a unique port by IIS. However, you are not stopping the _IIS host_.  Sites can be stopped and started on an _individual_ basis.

### Stopping a Single Site

To stop an IIS website, you will use the `Stop-IISSite` cmdlet. By default, the site that you created earlier should be in a `Started` state. If you stop the site and thus prevent access to _MyWebsite_, run `Stop-IISSite` providing the name as shown below. This code stops the _MyWebsite_ site from being served by IIS. After stopping the site, you will no longer be able to access it.

```powershell
PS> Stop-IISSite -Name "MyWebsite"
```

An example of inspecting the website’s state as `Started`, stopping and inspecting the state again is shown below. In this example, you are:

1.  Getting the status of the _MyWebsite_ site using `Get-IISSite`.
2.  Execute the `Stop-IISSite` cmdlet against the _MyWebsite_ site. This cmdlet shuts down access to the website. Since this action is making operational changes you will be prompted for confirmation.
3.  Running `Get-IISSite` again to verify that _MyWebsite_ site is stopped by noticing the `Stopped` state.

![Getting, stopping, and confirming MyWebsite state](https://adamtheautomator.com/wp-content/uploads/2020/06/Untitled-46-1024x311.png)

Getting, stopping, and confirming MyWebsite state

### Stopping All Sites

Above you stopped a single site but you can also stop all sites just as easily. By using the pipeline and piping the output of `Get-IISSite` to `Stop-IISSite`, PowerShell will enumerate all sites and stop them all. In the below code example, the optional `Verbose` switch parameter is used to show more information.

```powershell
Get-IISSite | Stop-IISSite -Verbose
```

![Stopping all IIS sites with PowerShell](https://adamtheautomator.com/wp-content/uploads/2020/06/Untitled-47-1024x171.png)

Stopping all IIS sites with PowerShell

> _You can also stop all sites in IIS by stopping the W3SVC or World Wide Web Publishing Service. Stopping the Windows service shuts down IIS and prevents all sites being served. If you do this, however, the sites may still show to be in a Started state._

### Starting a Single Site

Let’s say you’ve made some changes to the _MyWebsite_ site and need to start it back up again. It’s time to use the `Start-IISSite` command. To do that, simply specify the name just as you did by using the `Stop-IISSite` cmdlet.

```powershell
PS> Start-IISSite -Name 'MyWebsite'
```

When executed, you can then inspect the state again using `Get-IISSite`. When you do, you should then see similar output to the screenshot below.

![Checking the status of MyWebsite using Get-IISSite and starting the site with Start-IISSite](https://adamtheautomator.com/wp-content/uploads/2020/06/Untitled-48-1024x235.png)

Checking the status of _MyWebsite_ using `Get-IISSite` and starting the site with `Start-IISSite`

And now your site should be available again at _[http://localhost:8088](http://localhost:8088)_ if you refresh your browser.

### Starting All Sites

Similar to how you stopped all sites from being published, you can use the pipeline to start all websites on your IIS host as well.

```powershell
PS> Get-IISSite | Start-IISSite
```

Once again, you are getting all of the IIS sites being served and using the pipeline to start each one. Your output should look similar to the screenshot below.

![Using the pipeline to start all sites on host](https://adamtheautomator.com/wp-content/uploads/2020/06/Untitled-49-1024x60.png)

Using the pipeline to start all sites on host

## Managing Web Bindings

It’s now time to start performing some common administrative tasks on the _MyWebsite_ site. Of of the most common task is changing the web bindings.

When you created the _MyWebsite_ site, you used the binding syntax of `*:8088:`. This syntax represented listening on the IP address 127.0.0.1, on port 80 with no HTTP headers. Let’s say now you’ve decided that you instead want the site to listen on port 9000 instead. To do this, you’ll need to modify the site bindings.

### Inspecting Existing Bindings

Before you can change the site’s bindings, you should first inspect the current configuration. One way to do that is to inspect the `Binding` property returned by `Get-IISSite`. Notice in the next code snippet how to do that. In the snippet, `Get-IISSite` is querying the _MyWebSite_ site, and only returning the `Bindings` property.

```powershell
PS> (Get-IISSite -Name 'MyWebsite').Bindings
```

When you inspect just the `Bindings` property, PowerShell will return an object with a few different pieces of information as shown below.

![Example 1: Finding binding information](https://adamtheautomator.com/wp-content/uploads/2020/06/Untitled-50-1024x196.png)

Example 1: Finding binding information

If you’d like to only see the binding information, you can specifically reference the `bindingInformation` property as shown below.

![Example 2: Finding binding information](https://adamtheautomator.com/wp-content/uploads/2020/06/Untitled-51-1024x85.png)

Example 2: Finding binding information

### Removing Bindings

If you’d like to change what port a site listens on, you must first remove the existing binding tying it to that port. To remove the binding, you first have to stop the site.

```powershell
PS> Stop-IISSite -Name 'MyWebsite'
```

Once the site is stopped, you can now remove the existing binding tying the _MyWebsite_ site to port 8088. To do that, you can use the [`Remove-IISSiteBinding` cmdlet](https://docs.microsoft.com/en-us/powershell/module/iisadministration/remove-iissitebinding).

To remove the binding for _MyWebsite_ as defined earlier, below you can see an example of using `Remove-IISSiteBinding` to do just that. Below, you are providing the name of the site and specifying the binding syntax discovered earlier.

```powershell
PS> Remove-IISSiteBinding -Name 'MyWebsite' -BindingInformation "*:8088:"
```

When you execute the code, you will be prompted to confirm your decision since you are doing something destructive as shown below.

![Removing site binding using Verbose parameter](https://adamtheautomator.com/wp-content/uploads/2020/06/Untitled-52-1024x149.png)

Removing site binding using Verbose parameter

> _There’s no limit to how many bindings you can have. You can just as easily have kept the original binding and added TCP port 9000 as a new binding._

Now you can run `Get-IISSite -Name 'MyWebsite'` again. You’ll now see that the binding information has been removed as shown by the blank value under `Bindings`.

![Confirming the old bindings were removed](https://adamtheautomator.com/wp-content/uploads/2020/06/Untitled-53-1024x141.png)

Confirming the old bindings were removed

Even though the site is published, IIS has no way of knowing how to route traffic to your site.

It is important to have at least one binding assigned to your site. To show you the importance, try to navigate to [http://localhost:8088/index.html](http://localhost:8088/index.html) again. If you were using Mozilla Firefox web browser, you may see this message below.

![Can't establish a connection](https://adamtheautomator.com/wp-content/uploads/2020/06/Untitled-54-1024x427.png)

Can’t establish a connection

### Creating New Bindings

In the last section, you removed the only site binding _MyWebsite_ had. While this broke the site, it’s only a temporary problem. It’s time to correct this issue by creating a new binding.

To create a new binding, use the `New-IISSiteBinding` cmdlet. Since you need to bind port 9000 to the _MyWebsite_ site now, specify the correct binding syntax as shown below.

```powershell
PS> New-IISSiteBinding -Name 'MyWebsite' -BindingInformation "*:9000:"
```

Once you’ve created the new binding, start up the site again with `Start-IISSite`. Recall that to create this new binding, IIS required the site to be brought down.

When the site starts again, you should now be able to access it on port 9000. To verify this, open your web browser of choice and navigate to [http://localhost:9000](http://localhost:9000). You should now see the webpage is working again under port 9000.

![Same page, different TCP port](https://adamtheautomator.com/wp-content/uploads/2020/06/Untitled-55-1024x277.png)

Same page, different TCP port

### Removing a Website

This you just went through a tutorial and don’t intend to keep the _MyWebsite_ site around for good, it’s time to clean it up. To remove a site, use the  `Remove-IISSite` cmdlet.

Removing an IIS site can be a dangerous undertaking especially if you’re removing a site on IIS that’s hosting other production websites. To verify you’re removing the right site, it’s recommend to use the common [`WhatIf`](https://adamtheautomator.com/powershell-whatif/ "WhatIf") PowerShell parameter. This parameter allows you to inspect what _would_ have happen if the command would have actually run.

You can see an example of removing the _MyWebsite_ site using the `WhatIf` parameter below.

```powershell
Remove-IISSite -Name 'MyWebSite' -WhatIf
```

![Being careful with destructive cmdlets by using -WhatIf !](https://adamtheautomator.com/wp-content/uploads/2020/06/Untitled-56-1024x43.png)

Being careful with destructive cmdlets by using `-WhatIf` !

If everything looks good, let go of the safety bar and re-run the code, this time without the `-WhatIf` parameter.

> _When using the `Remove-IISSite` cmdlet, the site is not deleted. It is removed from the IIS configuration. Files for the website remain intact._

## Summary

In this article, you’ve learned to create a website using the IISAdministration module. You’ve seen how to perform administrative operations necessary to maintain a website. You now know enough of the basics to work with any modern IIS host using PowerShell!

## Further Reading

*   [**_IISAdministration PowerShell Cmdlets Reference_**](https://docs.microsoft.com/en-us/iis/get-started/whats-new-in-iis-10/iisadministration-powershell-cmdlets)
*   [**_Stay Up-To-Date on the latest in IIS Technology (iis.net)_**](https://www.iis.net/)
*   [**_Microsoft IIS Administration API_**](https://docs.microsoft.com/en-us/IIS-Administration/)

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-iis%2F&text=PowerShell%20IIS%20Mastery%3A%20Create%20and%20Manage%20Websites)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-iis%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-iis%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2019/06/5d238ae5c824b514689ea5a5.jpg)

### [Managing IIS App Pools: A PowerShell Tutorial](/powershell-iis-2/)

Learn to create, modify, and remove IIS application pools using PowerShell. Your guide to efficient IIS management.

![](https://adamtheautomator.com/wp-content/uploads/2019/06/5d238ae5c824b514689ea564.jpg)

### [Mastering IIS Certificate Requests with PowerShell](/iis-certificate-request/)

Secure your IIS websites like a pro. Step-by-step guide to IIS certificate requests and binding using PowerShell.

![](https://adamtheautomator.com/wp-content/uploads/2026/06/26995-troubleshoot-dns-issues-powershell-codex.webp)

### [Troubleshoot DNS Issues with PowerShell](/troubleshoot-dns-issues-powershell/)

Troubleshoot DNS issues with PowerShell by testing name resolution, DNS client settings, cache entries, and network connectivity in a repeatable workflow.

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
