Rename Alternate Access Mappings

Another chapter in renaming everything in SharePoint…

If you’re looking for a good overview of what an alternate access mapping is, check out Edwin’s article on configuring alternate access mappings.

When you start creating an alternate access mapping, the collection takes the name of the web application. However, this may not be what you want – the context when working with web applications is different than the AAMs. In addition, once the AAM is created, if you rename the web application the name of the AAM isn’t changed.

The name is actually the name of the AAM collection. When you look at the alternate access mappings, each URL is a mapping; the mappings for a web application are a collection, and that’s where the name in the selector comes from, as indicated below.


The AAM collection is a property of the Web Application, so to get a handle on it:

$sp=get-spwebapplication http://sitename

Or, to list web applications and fetch one by ID:

PS C:\Users\Administrator> get-spwebapplication | select displayname, id

DisplayName                             Id
-----------                             --
SharePoint - 16275                      584e9d9c-e652-4b1d-9d77-3ffd033fe14a
SharePoint - 80                         51ca3304-3629-4fe7-9429-638db13ae225

PS C:\Users\Administrator> $sp=get-spwebapplication -id 51ca3304-3629-4fe7-9429-
PS C:\Users\Administrator> $sp

DisplayName                    Url
-----------                    ---
SharePoint - 80                http://gemini2010/

Now that you have the web application, the AAM collection is in the property “alternateurls,” which you can hook like this:

$auc = $sp.alternateurls

Now the $auc variable has the alternate access mapping collection, and it’s simple to rename it:

$"Primary Corporate Website"





If you have a number of SharePoint sites to work with, this is much easier than trying to figure out if the intranet workflow site is “SharePoint – 2580” or “SharePoint – 3740”

SharePoint 2010: Rename the SharePoint State Service Database

Continuing on a quest to rename everything in SharePoint. You can find the first article here.

Rename the SharePoint State Service Database

The State Service in SharePoint 2010 is a service application that manages user state across browser requests. The SharePoint State Service is required by InfoPath Forms Services, the Chart Web Part, and certain Visio 2010 scenarios. You can find the State Service in Central Admin under Application Management – Manage Service Applications. There will be one or more State Service applications and associated proxies.

As usual, if the state service was created by the SharePoint Configuration Wizard, or you create it without editing the database name, the database will be created with a GUID on the end, such as:

StateService_5536604e93df4369a916cf408e0c3866  (ew!)

So let’s check out our state service in PowerShell. Open the SharePoint 2010 Management Shell (Start –> All Programs –> Microsoft SharePoint 2010 Products –> SharePoint 2010 Management Shell). To start, try a simple:

Get-SPDatabase | Select Name

This will list the SharePoint databases, and you should easily spot your State Service database. If for some reason you don’t know the name of the State Service Database, you can list all state service databases with this command:

Get-SPDatabase | Where-Object { $_.Type -eq "Microsoft.Office.Server.Administration.StateDatabase" }

Every SharePoint object has an ID (a GUID), and the easiest way to get a reference to a SharePoint object is by using that ID. You can get the ID for databases with this command:

Get-SPDatabase | SELECT Name, ID

Once you find the ID for your State Service Database, you can get a handle on it with this command:

$db=Get-SPDatabase -id {guid}

Next (and this is a common step with SharePoint Service databases; the trick is always figuring out how) you have to dismount the database:

Dismount-SPStateServiceDatabase -Identity <DatabaseID>

For “DatabaseID” you can either paste in the GUID we copied earlier, or you can use the $db variable as a hook to the database itself. $db.Id won’t work unless you cast it to a string first.

You’ll be asked to verify that you want to do this:

Are you sure you want to perform this action?
Performing operation "Dismount-SPStateServiceDatabase" on Target "SP_Dev_StateService_DB".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help
(default is "Y"):

A simple “Y” and enter will dismount the database. Now you can go to SSMS to rename the database — right-click on the database and select “Rename” or in T-SQL:


After you’ve renamed the database, then mount it again with the command

Mount-SPStateServiceDatabase -Name "<DatabaseName>" -DatabaseServer "<ServerName>"

And you’re all set.

If you completely screw up the database somehow, or feel it’s corrupted, there’s no critical data in the database – simply delete it and create a new one with the command:

New-SPStateServiceDatabase -Name "<StateServiceDatabase>" -ServiceApplication $serviceApp

Which will create a state service database and associate it with the State Service.

What Makes a Good Technical Article

So we have a particular error in SharePoint and two articles online about how to resolve it. These two articles are exceptional examples of good and bad ways to write a technical article. What makes the “bad way” such a great example is that it’s bad in the very subtle way that technical articles can be. It’s also a perfect textbook example of why I always need to rein myself in when I want to rush off to write a technical article.

Here is the first article:

“The given key was not present in the dictionary” issue in SharePoint 2010 RTM (alipka)

It seems to fairly straightforward. But if you try to correct the issue, you’ll see the author gives the fix:

I had to grant AUTHENTICATED USERS READ permission (probably read ‘some’ information would be enough) to the MOSS accounts (I granted to the DB access account and managed services account). After that an IISRESET and it worked.

Easy enough. Let’s just go take care of this. I just have to grant authenticated users read permission to some accounts. Okay.

… where? SQL Server? SharePoint? Local users and groups? There’s mention of an IISReset – maybe somewhere in IIS? Nope. Where?

Reading through the comments, the author mentions the Security tab in Active Directory Users and Computers. Ah. So I go to a domain controller I have handy and open a user account in the applet:

User dialog in Active Directory applet.

User dialog in Active Directory applet.

No “Security” tab. [sigh] Okay, let’s take a look at another article on the same subject:

The given key was not present in the dictionary Error when Validating User Accounts (

Here the author walks through eight simple steps that explain where to go and what to do. (And we find out quickly that yes, it’s in the Active Directory Users and Computers snap-in, but that you have to enable Advanced Features to get the Security tab…)

Any time you’re posting a technical note, how-to, or walkthrough, make sure to copy exactly what your end user is going to have to do. I can’t tell you how often I’ve walked through the steps myself and discovered I assumed some part of the procedure that an end user would have issues with. (Another classic “Oops, did you need to know that?” is neglecting to note referenced assemblies, include files, or utility classes)