CHUVASH.eu

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
Advertisements

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

    Giles

  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”]
    $userProfile.Commit()
    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

    Hi,
    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?
    Thanks

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

Вула Чăвашла

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

Discovering SharePoint

And going crazy doing it

Bram de Jager talking Office 365, SharePoint and Azure

My view and thoughts on Productivity and more.

My programming life

and everything in between

SharePoint Development Lab by @avishnyakov

It is a good place to share some SharePoint stories and development practices.

SharePoint Dragons

Nikander & Margriet on SharePoint

RealActivity - Real-time and trustworthy

Blog site of founder, RealActivty - Paul J. Swider

Mai Omar Desouki - Avid SharePointer

Egyptian & Vodafoner - Senior SharePoint Consultant

Cameron Dwyer | Office 365, SharePoint, Outlook, OnePlace Solutions

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

paul.tavares

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

SPJoel

SharePoint for everyone

SharePointRyan

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, ya mama

Treacle tarts for great justice

... And All That JS

JavaScript, Web Apps and SharePoint

%d bloggers like this: