Renaming an AD group in SharePoint 2013

This post is part 3 of the guide to move Active Directory Groups in SharePoint 2013. We have gotten the identity claim in part 1 and migrated the AD group in part 2 but now we want to change the name for the SharePoint User Information List.

We have seen that the Name did not change after migrating the AD group and we have to change this afterwards with PowerShell. The command move-spuser effects the whole farm but we can only change the name per site collection.

The following posts will help you get the claim and move an AD group in SharePoint 2013:

  1. Get identity claim for AD groups in SharePoint 2013
  2. Migrating AD groups in SharePoint 2013
  3. Renaming an AD group in SharePoint 2013


Scenario

We have two AD groups and we have migrated from one to the other.

Domain\GroupWillBeMigrated (no entry in User Information List)
Domain\MigratedGroup (Migrated group from domain\groupwillbemigrated)

clip_image002

The account is pointing to the correct AD group but we want to change the Name to also point to the new group.

Renaming AD group in SharePoint 2013 User Information List

We are going to run the following command for each site collection. You can always change this script to run multiple times for each ad group change but I am currently showing this for one change.

$sites = get-spsite -limit all

foreach ($site in $sites)

{

$user = get-spuser -identity “c:0+.w|s-1-5-21-2519571660-2376940383-2348130139-2109” -web $site.url -ErrorAction SilentlyContinue

If($user)

{

set-spuser -identity $user -displayname “PEET\MigratedGroup”

Write-host –foregroundcolor green “Changed the name for $($site.url)”

}

Else

{

Write-host –foregroundcolor red “The specified group does not exist in $($site.url)”

}

}

clip_image004

clip_image005

Leave a Reply

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