当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 使用 PowerShell 更新 SharePoint 中的用户配置文件属性

作者:精品下载站 日期:2024-12-14 14:08:27 浏览:12 分类:玩电脑

使用 PowerShell 更新 SharePoint 中的用户配置文件属性


SharePoint 用户配置文件属性通常从 Active Directory 导入,以提供有关 SharePoint 用户的信息。有时,我们可能需要手动更新 SharePoint 用户配置文件。我的方案是从 SharePoint 库更新用户个人资料图片。这是我的 PowerShell 脚本:

用于更新用户配置文件属性的 PowerShell 脚本:


#Configuration Variables
$MySiteURL = "https://Mysite.Crescent.com"
$UserLogin="Crescent\Salaudeen"

#Get User Profile Objects
$ServiceContext  = Get-SPServiceContext -site $MySiteURL
$UserProfileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext)

#Check if user Exists
if ($UserProfileManager.UserExists($UserLogin)) 
{
    #Get the User Profile
    $UserProfile = $UserProfileManager.GetUserProfile($UserLogin)

    #Update user profile picture Property
    $userProfile["PictureURL"].Value = "https://intranet.Crescent.com/UserProfileImages/Salaudeen.jpg"
    $userProfile.Commit()  
    write-host "User Picture Updated Successfully!" -f Green
}
else
{
    write-host "$($UserLogin) Not Found!" -f Red
}  

确保在用户配置文件服务应用程序的“管理用户属性”页面下删除 SharePoint 用户配置文件属性和 Active Directory 之间的映射。如果定义了映射,则下次运行用户配置文件同步时,您的更新将被覆盖!

[玩转系统] 使用 PowerShell 更新 SharePoint 中的用户配置文件属性

更新后,运行增量/完整搜索爬网以使更新反映在 SharePoint 搜索中!

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯