Learn more about SQL Server tools

mssqltips logo
 

Tutorials          DBA          Dev          BI          Career          Categories          Webcasts          Whitepapers          Today's Tip          Join

Tutorials      DBA      Dev      BI      Categories      Webcasts

DBA    Dev    BI    Categories

FREE Webcast - Delivering Microsoft SQL Server High Availability on AWS
 

Configuring Alternate Access Mapping in SharePoint 2010 using Windows PowerShell


By:   |   Read Comments   |   Related Tips: > Sharepoint

Problem

In a previous tip on Configuring Alternate Access Mapping in SharePoint 2010, we've seen how to configure alternate access mapping for a SharePoint 2010 site using the Central Administration page. How do we do this task using Windows PowerShell instead?

Solution

Windows PowerShell is an extensible command-line shell and associated scripting language built on top of the .NET Framework v2.0. Being the standard scripting environment for almost all of the current Microsoft server products, it is essential for the SharePoint administrator to learn a few things about Windows PowerShell. And with the latest version of SharePoint comes the specific PowerShell cmdlets for managing and administering site collections, web applications, user permissions and anything that has something to do with SharePoint. While learning Windows PowerShell scripting can be a bit overwhelming, you can start by learning the SharePoint-specific cmdlets to perform basic administrative tasks (or even more complex ones) . An introduction to Windows PowerShell is available from these two tips - Part 1 and Part 2. While they were written with the SQL Server DBA in mind, the concepts to get started with Windows PowerShell are the same.

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.

sharepoint

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.

management shell

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
management shell

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
management shell

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
sharepoint

Let's use the format in the example to create the alternate access mapping. When prompted for a WebApplication parameter 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
management shell

You can confirm this by checking the Alternate Access Mappings page in SharePoint Central Administration.

site actions
Next Steps


Last Update:


next webcast button


next tip button



About the author
MSSQLTips author Edwin Sarmiento Edwin M Sarmiento is a Microsoft SQL Server MVP and Microsoft Certified Master from Ottawa, Canada specializing in high availability, disaster recovery and system infrastructures.

View all my tips





Post a comment or let the author know this tip helped.

All comments are reviewed, so stay on subject or we may delete your comment. Note: your email address is not published. Required fields are marked with an asterisk (*).

*Name    *Email    Email me updates 


Signup for our newsletter
 I agree by submitting my data to receive communications, account updates and/or special offers about SQL Server from MSSQLTips and/or its Sponsors. I have read the privacy statement and understand I may unsubscribe at any time.



    



Learn more about SQL Server tools