อัปเดตคุณสมบัติโปรไฟล์ผู้ใช้ใน SharePoint โดยใช้ PowerShell
โดยทั่วไปคุณสมบัติของโปรไฟล์ผู้ใช้ 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 ภายใต้หน้า "จัดการคุณสมบัติผู้ใช้" ของแอปพลิเคชันบริการโปรไฟล์ผู้ใช้ หากมีกำหนดการแมป การอัปเดตของคุณจะถูกเขียนทับเมื่อมีการซิงค์โปรไฟล์ผู้ใช้ในครั้งต่อไป!
เมื่ออัปเดตแล้ว ให้เรียกใช้การรวบรวมข้อมูลการค้นหาแบบเพิ่มหน่วย/ทั้งหมดสำหรับการอัปเดตเพื่อแสดงในการค้นหา SharePoint!
