Create Redirect Rule with PowerShell

This is a follow-up to my recent post showing how quick the creation of a self-signed certificate can be. Now that you have an SSL certificate it is helpful to ensure that all calls to your site go through on SSL. The easiest way to do this ( and save yourself typing time) is to create a Url rewrite rule via IIS’s Url Rewrite Module,

Ensure Url Rewrite Module is Installed

For redirect rules to be written you need to confirm the module is installed. The best way to do this is to open up IIS, select a web application, and check for the module’s icon.

Url Redirect Rule - Url Rewrite Module Icon

If you do not see the icon, then you will need to install the module before moving on. You can install the module through the Web Platform Installer or the link at

Run the Create Redirect Rule Script

  1. Download and save as CreateRedirectRule.ps1 from Gist,
  2. Open a PowerShell command prompt, ensure you are running it as Admin
  3. Change directory to the location you saved to in step 1
  4. At the prompt enter, and complete the requested parameters

    Url Redirect Rule -Script with Prompts

    OR you can submit the parameters at run

    .\CreateRedirectRule.ps1 -SiteBinding "" -RuleName "Redirect to SSL"

    Url Redirect Rule -Script in singleline

Script for Reference


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.