Quickly get and update sharepoint user profile properties

I can't count how many time I had to get or update user profile properties in my life. Either for one shot (Central administration UI can help but not always the most practical) or for bulk scripts.

Always opening a powershell windows (in my case using PowerGUI), find part of old script I've wrote in the past, copy past the SPServiceContext & UserProfileManager call, then playing with the UserProfileManager.GetUserProfile("my_user") for getting the profile and then forget the script forever.

It was still ok when our user format was windows one: domain\samaccountname but it became really painful when we switch to claims : i:0e.t|claimsprovidername|$User@email.com.

For addressing this cumbersome task, I've end up writting a few scripts for speeding up this boring task

  • Get-SPUserProfileProperty.ps1 1
  • Set-SPUserProfileProperty.ps1 2

These scripts could be found here : https://github.com/camous/sharepoint-powershell. It requires a little configuration in the default value of parameters for defining the mysite host ($MysiteUrl) and the account format ($AccountFormat) (value which are obviously not changed everyday) on both scripts and you're done

(below for Set-SPUserProfileProperty)

    [string]$MysiteUrl = "https://mysite.domain.com",
     [string]$AccountFormat = "i:0e.t|claimsprovidername|$User@email.com",

getting all properties for my account
get my PictureUrl
updating my Fax value

Fabien Camous

Read more posts by this author.