Quantcast
Channel: SharePoint Diary
Viewing all articles
Browse latest Browse all 1058

Update User Profile Properties in SharePoint using PowerShell

$
0
0
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 there to remove mapping between SharePoint user profile property and Active Directory under User profile service application's "Manage User Properties" page. If there is a mapping defined, when next time user profile sync runs, your updates will be overwritten!
sharepoint 2010 update user profile properties powershell

Once updated, Run incremental/full search crawl for the updates to reflect in SharePoint search!

Viewing all articles
Browse latest Browse all 1058


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>