SharePoint: Update User Profile Property Values for All Users

SharePoint: Update User Profile Property Values for All Users


This script can be used to update any user profile property value. In my case I used this for removing "No Title" in SharePoint 2010 Org Chart.

Environment

No Job Tile in AD Attributes. No Mapping in SharePoint 2010 UPA.

Scenario

Organization Chart shows "No Title". Functional Team requested not to add Job Title in AD. Alternatively Roles are used. No Roles should be used in ORG CHART.

Requirement

Remove "No Title" from ORG CHART. Do not update roles in ORG CHART. Do not update title in AD.

Considerations

Do not execute this script to update values if it is mapped in AD Do not try in production with out testing Please update the CSV file with NTName and with the field name as required The CSV file should have headers with NTName and desired field name (Use Internal Name) No CSV file available - Please create one as required.

PowerShell Script

$mySite = "mysitename" 

$upAttribute = "<Any User Profile Property Name>" 

 

#Get site objects and connect to User Profile Manager service

$site = Get-SPSite $mySiteUrl 

$context = Get-SPServiceContext $site 

$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context) 

 

#Create Lists from each item in CSV file

$csvData = Import-Csv -Path "Path of the CSV File" 

foreach ($line in $csvData) 

{ 

#Check to see if user profile exists

if ($profileManager.UserExists($line.NTName)) 

{ 

#Get user profile and change the value

$up = $profileManager.GetUserProfile($line.NTName) 

$up[$upAttribute].Value = $line.PropertyVal 

$up.Commit() 

} 

else 

{ 

write-host "Profile for user"$line.NTName "cannot be found" 

} 

} 

 

#Dispose of site object

$site.Dispose()

Download Script

Gallery Link Enjoy PowerShell :)
Sort by: Published Date | Most Recent | Most Useful
Comments
Page 1 of 1 (1 items)