Friday, 13 September 2013

Configuring Alternate Access Mapping in SharePoint 2010 with powershell

 

Configuring Alternate Access Mapping in SharePoint 2010 with powershell

To manage SharePoint using Windows PowerShell, you can launch the SharePoint 2010 Management Shell from the Start menu. Make sure that you run the management shell as administrator to perform administrative tasks.

You can learn more about the SharePoint-specific cmdlets by using the Get-Help cmdlet and passing it a wildcard with the value *-SP*. This is because the SharePoint-specific cmdlets have the SP prefix in the verb portion of the cmdlet.
There are more than 500 SharePoint-specific cmdlets so don't get overwhelmed. For configuring alternate access mappings, we will be using the following SharePoint-specific cmdlets
  • Get-SPAlternateURL
  • New-SPAlternateURL
The Get-SPAlternateURL cmdlet is used to retrieve all alternate URLs for a specific SharePoint web application. To know more about this specific cmdlet and it's usage, you can also use the Get-Help cmdlet.
Get-Help Get-SPAlternateURL -examples
From the previous tip, let's retrieve the list of all alternate URLs for the default SharePoint site that I have created -http://sharepoint1
Get-SPAlternateURL -WebApplication http://sharepoint1
Note that the SharePoint website does not have any other alternate URLs by default. To create an alternate access mapping for this SharePoint site so that internal users can use the corporateportal.testdomain.com URL to access the site, we will use the New-SPAlternateURL cmdlet. This cmdlet creates a new public or internal URL for the specified web application zone or resource. Again, to know more about this cmdlet and it's usage, we'll use the Get-Help cmdlet
Get-Help New-SPAlternateURL -examples
Let's use the format in the example to create the alternate access mapping. When prompted for a WebApplicationparameter value, enter the URL for the web application that you want to apply an alternate URL for. In this example, I passed the parameter value http://sharepoint1
New-SPAlternateURL http://corporateportal.testdomain.com -Zone "Intranet"
To review if your changes have taken effect, you can re-run the Get-SPAlternateURL cmdlet. Notice that you now have a new alternate URL to access the http://sharepoint site
Get-SPAlternateURL -WebApplication http://sharepoint1
You can confirm this by checking the Alternate Access Mappings page in SharePoint Central Administration.

No comments:

Post a Comment