共用方式為


SharePoint 2010 Organization Browser - Expose more than just User, Title and About Me (Sort Of).

One of my favourite customers was very keen to display the OOB Organisation Browser web part on several of their pages but they wanted to expose more than the default values against the user. I know this can be done by clicking across to the users profile page but the extra click was not acceptable.

As you will know this is a Silverlight control and therefore not customisable that easily so the solution I came up with was to essentially grab the properties they wanted to expose and copy them all in to the 'About Me' portion of the user profile.

They have somewhere in the region of 1000 users on this particular system so obviously I enlisted the help of our friend PowerShell.

The code looks something like the below, please be aware of the warning! and that this will obviously not keep the data fresh... Also it might be worth stopping the users ability to edit the About Me field so they are not too disappointed when you run it again and clear all their entries!

WARNING! THIS CODE WILL REMOVE ALL INFORMANTION IN THE ABOUT ME FIELD FOR ALL USERS BEFORE IT ADDS THE NEW PROPERTIES!

#Add Sharepoint PowerShell Modules
Add-PSSnapin "Microsoft.SharePoint.PowerShell"

#Get the Web application           
$site=new-object Microsoft.SharePoint.SPSite("https://sharepoint2010/");    

#Get the Service Context of the Web Application      
$serviceContext = Get-SPServiceContext $site;           
$site.Dispose();           

#Get the User Profile Manager
$upm = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext);

#Get all of the user profiles for the selected User Profile manager
$profiles = $upm.GetEnumerator()

#Execute a For Each loop against every user
foreach ($userProfile in $profiles)
{

#Delete all values in the AboutMe Section of the User Profile for ALL Users     
$am = $userProfile["AboutMe"]        
$am.Clear()     
     
#Set the AboutMe property to the value of am (empty)          
$userProfile["AboutMe"].Value = $am;      
    
#Save the profile changes back to the User Profile store           
$userProfile.Commit()

#Get the fields you want to expose in the AboutMe Section of the User Profile and on the Org Browser

$userProperty1 = $userProfile["WorkEmail"].Value
$userProperty2 = $userProfile["Office"].Value

#Concatinate the values you have and add them to the AboutMe Section using the silverlight encoding

$userProfile["AboutMe"].Value = "Email: "+"$userProperty1" + "
" + "Office Location: " +"$userProperty2"
#Commit the changes to the user profile 

$userProfile.Commit();

}

Essentially it just grabs existing profile properties and puts them into the 'About Me' field.. Don't forget to use "
" which is Silverlight encoding for new line.

Thanks to Dave Little for his expert help with that :)

I just ran the script on my test VM with 1000 users and it completed in sub 30 seconds.

The results are a little something like this:

WARNING! THIS CODE WILL REMOVE ALL INFORMANTION IN THE ABOUT ME FIELD FOR ALL USERS BEFORE IT ADDS THE NEW PROPERTIES!

Hopefully someone will find this useful - I scoured the internet and could not find anything that did what I wanted :)

Enjoy!

Andy

Comments

  • Anonymous
    January 01, 2003
    thank you
  • Anonymous
    September 11, 2014
    Is it possible to add mailto: links to this? thank you for the solution btw!