kwizcom banner advertisement

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 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!

Tags: update user profile properties sharepoint 2013 powershell, update user profile property sharepoint, edit user profile property sharepoint 2013, edit user profile property sharepoint 2013 powershell, sharepoint 2013 update user profile property powershell
Update User Profile Properties in SharePoint using PowerShell Update User Profile Properties in SharePoint using PowerShell Reviewed by Salaudeen Rajack on December 22, 2015 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.