Search This Blog

Friday, January 17, 2014

SharePoint 2010: after domain rename

Add-PSSnapin Microsoft.SharePoint.Powershell
$rootWeb = Get-SPWeb "yoursite"
$oldDomain = "yourOldDomain"
$newDomain = "yourNewDomain"
#loop through all users in the $rootWeb, change the login name and execute the EnsureUser method
foreach ($user in $rootWeb.Users) {
  $newLogin = $user.UserLogin -replace $oldDomain, $newDomain
  $rootWeb.EnsureUser($newLogin)
}

1 comment:

  1. Hey I know this is off topic but I was wondering if you knew of any widgets I
    could add to my blog that automatically tweet my newest twitter updates.

    I've been looking for a plug-in like this for quite some time
    and was hoping maybe you would have some experience with something like this.
    Please let me know if you run into anything.
    I truly enjoy reading your blog and I look forward to your new updates.


    Look at my website; http://nouveauclashofclanstriche.blogspot.com/

    ReplyDelete