Add Alternate Access Mapping in SharePoint using PowerShell

Alternate Access Mappings helps to expose a SharePoint web application to different URLs in scenarios such as publishing, load balancing, reverse proxy, etc. Each web application can have up to five different URLs through alternate access mapping, with the “Default” zone as mandatory and other optional zones.

How to Configure Alternate Access Mapping in SharePoint Central Administration?

Follow these steps to set alternate access mapping in SharePoint:

  • Go to the SharePoint 2016 Central Administration Site, Click on System Settings from Left navigation menu.
  • From the “System setting” page, click on “Configure Alternate Access Mappings” link under in the “Farm Management” group.
  • You will be presented with the Alternate Access Mappings page. Select your desired web application to get the AAM settings for the specific web application.
powershell add alternate access mapping

Here, The public URL is the address of the Web Application, where the traffic will be routed to. Internal URLs are what’s entered in the browser, and it’s either transformed/mapped into the Public URL.

To add an alternate access mapping, with the target web application selected, click on “Edit Public URL’s” link >> Enter the appropriate URL for the respective zone and hit Save to commit your changes.

sharepoint 2013 alternate access mapping powershell

You can also use PowerShell to manage Alternate Access Mappings in SharePoint.

Add alternate access mapping SharePoint using PowerShell:

To add an entry to SharePoint alternate access mapping using PowerShell, use cmdlet: New-SPAlternateURL. Here is an example:

New-SPAlternateURL -WebApplication "https://intranet.crescent.com" -URL "https://portal.crescent.com" -Zone Internet

Add a binding to the web application in IIS:

But wait, You are not yet done. This is a common miss in SharePoint. Although you add AAM entry, You must also add IIS binding for the web application for initial redirect to the IIS site.

powershell set alternate access mapping

You can now access the existing SharePoint web application “https://intranet.crescent.com” using the new URL “https://portal.crescent.com”.

PowerShell to remove alternate access mapping:

To remove an existing AAM entry, use the PowerShell cmdlet: Remove-SPAlternateURL. Here is an example:

Get-SPAlternateURL -WebApplication "https://intranet.crescent.com" -Zone "Internet" | Remove-SPAlternateURL

Get SharePoint alternate access mappings using PowerShell:

To read all alternate access mappings for a given web application, use this PowerShell script.

Get-SPAlternateURL -WebApplication "https://intranet.crescent.com" | Format-table -AutoSize
 sharepoint powershell add alternate access mapping

Similarly, to get the AAM settings for a specific zone, say Internet, use:

Get-SPAlternateURL -WebApplication "https://intranet.crescent.com" -Zone "Internet" 

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

One thought on “Add Alternate Access Mapping in SharePoint using PowerShell

  • What if you have multiple frontend servers for load balancing ?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *