Update User Profile Properties in SharePoint using PowerShell
SharePoint User Profile properties are usually imported from Active Directory to provide information about SharePoint users. At times, we may have to update SharePoint user profiles manually. My scenario is to update user profile pictures from a SharePoint library. Here is my PowerShell script:
PowerShell Script to update User Profile Property:
#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
}
Make sure to remove the mapping between the SharePoint user profile property and Active Directory under the User profile service application’s “Manage User Properties” page. If a mapping is defined, your updates will be overwritten when the user profile sync runs next time!
Once updated, Run incremental/full search crawl for the updates to reflect in SharePoint search!
Hello, Thanks ! This is the only!!! scripts that works within 1 million scripts I found in the net
To be exact Im looking for a script to change a property for all user, but none seems to work 🙁
Any suggestions?
Simple! Here is how to iterate through all user profiles: