CHunky Universe of Vigourous Astonishing SHarepoint :)

Access User Profile Properties from Powershell

To use only SPUser objects isn’t always sufficient. To get other properties we have to retrieve user profiles. Giles Hamson gives an example how to get and how to update user profile properties with powershell.

Here is an example how to get all work phones:

$url = "http://intranet/"
$site = Get-SPSite $url
$context = Get-SPServiceContext $site
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
$profiles = $profileManager.GetEnumerator()

while ($profiles.MoveNext()) {
  $userProfile = $profiles.Current
  $name = $userProfile.DisplayName
  $phone = $userProfile["WorkPhone"]
  $line = '{0};{1}' -f $name, $phone
  write $line

If you are not sure what properties are called, see the whole list by typing:

$userProfile.Properties | select name

6 responses to “Access User Profile Properties from Powershell

  1. Giles Hamson 2012-04-04 at 20:43

    Glad you found the post useful 🙂

    Kind regards


  2. anilkuchi 2012-04-23 at 19:36

    Can you tell me how can i copy the value of one user property to another in SharePoint .We have a custom property called Supervisor which will be entered by the user and i want to copy this property into Manager field in SharePoint , as the organizational profile is not working without manager field . I am writing this in power shell but it is giving me the following error “Unable to index into an object of type Microsoft.Office.Server.UserProfiles.UserProfile.” My Code is

    $consultantsupername = $userProfile[“ConsultantSupervisor”]
    $Managername =$userProfile[“Manager”]
    $userProfile[“ConsultantSupervisor”] = $userProfile[“Manager”]
    please help me …Thanks

    • Anatoly Mironov 2012-04-25 at 11:01

      If you update a value, you must do it through “Value”:

      $userProfile["WorkPhone"].Value = "46464646"
  3. Naveenkumar 2013-08-09 at 17:26

    Hi, can you please tell me how to get the user’s email address in powershell, from list which has a field of “person or group” which allows multiple selection..??

  4. Mita 2014-08-15 at 14:30

    Could you please let me know what needs to be done in order to update the user profile properties of the field “WorkPhone” if I want it to have the isReplicable property of it set to false?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Daniel Chronlund Cloud Tech Blog

News, tips and thoughts for Microsoft cloud fans

Вула Чăвашла

VulaCV - Чăвашла вулаттаракан сайт

Discovering SharePoint

And going crazy doing it

Bram de Jager - Architect, Speaker, Author

Microsoft 365, SharePoint and Azure

SharePoint Dragons

Nikander & Margriet on SharePoint

Mai Omar Desouki

PFE @ Microsoft

Cameron Dwyer

Office 365, SharePoint, Azure, OnePlace Solutions & Life's Other Little Wonders


Me and My doings!

Share SharePoint Points !

By Mohit Vashishtha

Jimmy Janlén "Den Scrummande Konsulten"

Erfarenheter, synpunkter och raljerande om Scrum från Jimmy Janlén

Aryan Nava

DevOps, Cloud and Blockchain Consultant


SharePoint for everyone


Ryan Dennis is a SharePoint Solution Architect with a passion for SharePoint and PowerShell

SharePoint 2020

The Vision for a Future of Clarity

Aharoni in Unicode

Treacle tarts for great justice

... And All That JS

JavaScript, Web Apps and SharePoint


Mostly what I know and share about...

%d bloggers like this: