SharePoint Migration - Export Alternate Access Mapping

This article is next in the series of articles on “SharePoint Migration & Planning Strategies". You can check out the previous articles in this series using the following links:

  1. SHAREPOINT MIGRATION: PLANNING & GUIDANCE ON SHAREPOINT OBJECTS
  2. SHAREPOINT MIGRATION – EXPORT IIS SETTINGS

In this article, we will look for the PowerShell Scripts to export “Alternate Access Mapping (AAMs)” settings from the source SharePoint Farm. This information will be helpful to track all the “AAMs” defined in SharePoint Farm.

In Step 1, we will add the PowerShell Snapin to the PowerShell Script as usual.

1

 

In Step 2, we define a function and initiate the export CSV file with Column Headers. For this demo, I am exporting a few important properties like “Incoming Url, Zone, Public Url” but you may query all possible properties as you deem fit.

In Step 3, we execute the “Get-SPAlternateURL” cmdlet to query the required properties.

In Step 4, we loop through the properties collection for all AAM Mapping and list out the queried properties for each mapping.

In Step 5, we add the content of properties for each of the AAM Mapping to the CSV file.

2

In Step 6, we will set the settings file path and call the function to export the AAM Mappings.

3

Once this script gets executed successfully, it will export the AAM Mappings in a CSV File, as shown below in Step 7.

4

We can see the exported mappings, as shown below in Step 8.

5
Code Reference

  1. Add - PSSnapin "Microsoft.SharePoint.PowerShell"  
  2.   
  3. function Get - Alternate - Access - URLs() {  
  4.     Try {  
  5.         if (Test - Path $settingsFilePath) {  
  6.             Remove - Item $settingsFilePath  
  7.         }  
  8.         Add - Content $settingsFilePath "Incoming Url, Zone, Public Url"  
  9.         $aamSettings = Get - SPAlternateURL | Select IncomingUrl, Zone, PublicUrl  
  10.         foreach($aamSetting in $aamSettings) {  
  11.             $incomingUrl = $aamSetting.IncomingUrl  
  12.             $zone = $aamSetting.Zone  
  13.             $publicUrl = $aamSetting.PublicUrl  
  14.             $settings = "$incomingUrl, $zone, $publicUrl"  
  15.             Add - content $settingsFilePath $settings  
  16.         }  
  17.     }  
  18.     Catch {  
  19.         Write - Host $Error - ForegroundColor Yellow  
  20.     }  
  21. }  
  22. Clear - Host $settingsFilePath = "C:\Prashant\PowerShell\SharePoint Migration\PowerShell - Get-Alternate-Access-URLs\Alternate-Access-Urls.csv"  
  23. Get - Alternate - Access - URLs  
That is all for this demo.

I hope you find it helpful.