Wednesday, 11 March 2015

Powershell for migrating Users in sharepoint 2010 to another domain

Below powershell script is used to migrate users from one domain to another in sharepoint 2010.



 if((Get-PSSnapin "Microsoft.SharePoint.PowerShell") -eq $null)
{
    Add-PSSnapin Microsoft.SharePoint.PowerShell
}



$users = Get-SPUser -web http://cp2010:6070/

foreach ($User in $Users) {
$domainName=$user.loginname.split('\')[0]
$userName=$user.loginname.split('\')[1]

if ($domainname -eq 'Test1')
{
#write-host $userName
$name='Test2\'+$userName
Move-SPUser -IgnoreSID -Identity $user -NewAlias $name
}
}


Just replace the Test1 to your old domain name and Test2 with your new domain name

No comments:

Post a Comment