Sylver SCHORGEN Blog's

Articles, astuces et news sur les technologies Microsoft et plus particulièrement tournant autour de Powershell

Hi everyone,

For one of my client, I had to migrate a SharePoint 2010 farm to a new domain. After reinstalling SharePoint from the beginning, I had to configure every service applications and migrate every content databases.

This post is the first of a series dedicated to migrated SharePoint from one domain to another.

The "problem" with the migrated database was that all user accounts and groups configured in SharePoint were from the old domain and not the new one. It was mandatory to migrate the old accounts to the new one (in the new domain). To do this task, I developped some PowerShell scripts. The script used to migrate users and group at the farm level is explained bellow. You can find this script here --> https://github.com/sschorgen/PowerShell/tree/master/SP10_Migrate-SPFromDomain

This script was written and executed on SharePoint 2010.

It is mandatory to create 2 CSV files :

  • 1 used to make the correspondence between the groups of the old domain and the new one
  • 1 used to make the correspondence between the usersof the old domain and the new one

You can find an example of the group CSV file below :

You can find an example of the user CSV file below :

One part of the script is used to migrate groups :

ForEach($Group in $Groups) {
Write-Host " --- MIGRATING GROUP " $Group.oldDomain "-->" $Group.newDomain -ForegroundColor Yellow -NoNewLine
$farm.MigrateGroup($Group.oldDomain, $Group.newDomain)
Write-Host " OK !" -ForegroundColor Green
}

Another part of the script is used to migrate users :

ForEach($User in $Users) {
Write-Host " --- MIGRATING USER " $User.oldDomain "-->" $User.newDomain -ForegroundColor Yellow -NoNewLine
$farm.MigrateUserAccount($User.oldDomain, $User.newDomain, $false)
Write-Host " OK !" -ForegroundColor Green
}

Once you have created your 2 CSV files, you can execute this command :

.\SP10_Migrate-SPUserAndGroupFromDomain.ps1 -UserMappingsCSV "D:\Scripts\users_to_migrate.csv" - GroupMappingsCSV "D:\Scripts\groups_to_migrate.csv"

Happy migration ;)

Facebook Like