Occasionally we will have a user that changes their last name and wants it to reflect the change across SharePoint. In order to aid this process I wrote this script to force a resynchronize of each instance of the user profile in the user information lists. The script accepts one argument, which is the username to resync (“DOMAN\User”).
$webapps = Get-SPWebApplication
foreach ($webapp in $webapps) {
[string] $login = $args[0]
$sites = get-spsite -Limit All -WebApplication $webapp
foreach ($s in $sites) {
write-host $s.url
$w = $s.RootWeb;
$u = get-SPUser -Web $w -limit all | Where-Object {$_.userlogin -eq $login}
if ($u -ne $null) {
write-host "`t$($w.url)"
Set-SPUser $u -SyncFromAD
write-host "`tUpdated"
}
}
}
No comments:
Post a Comment