有时AD 用户在AD中的信息更改,如部门,title,邮件地址,但是没有及时同步到 User Info list (SiteUserInfoList) http://sitecollectionURL/_catalogs/users/detail.aspx
本文分享从AD批量同步用户信息到User Info list的PowerShell 脚本,本方法适用于2010和2013。
在任意一台SharePoint Web或App server的SharePoint powershell 工具中执行如下脚本(可将脚本另存为ps1文件) :
$sites = Get-SPSite -Limit All
foreach($site in $sites)
{
$web = $site.RootWeb
if($web -ne $null) {
Write-Host "Processing: $site"
Get-SPUser -Limit All -web $web | foreach {
if ($site.WebApplication.UseClaimsAuthentication) {
$claim = New-SPClaimsPrincipal $_.LoginName -IdentityType WindowsSamAccountName
$user = $web | Get-SPUser -Identity $claim -ErrorAction SilentlyContinue
}
else
{
$user = $web | Get-SPUser -Identity $_.LoginName -ErrorAction SilentlyContinue
}
if ($user -ne $null)
{
Set-SPUser -Identity $user -web $web -SyncFromAD -ErrorAction SilentlyContinue
}
}
}
$web.Dispose()
$site.Dispose()
}