1

I'm using powershell to get some data from userprofile but I cant get to display the Managers field name as its a person field. What I currently get it domain\username . How can I get a display name .

   $Manager = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::Manager].Value

Above is how Im currently getting the Managers field.

Thanks in Advance

3

Try the below code, use the domain\username of the Manager and get the userprofile object of the Manager. From that you will be able to get all the details you require

$site=new-object Microsoft.SharePoint.SPSite("https://c05470sp10:7443");            
$serviceContext = Get-SPServiceContext $site;            
$site.Dispose();            
$upm = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext);            
$userProfile = $upm.GetUserProfile("company\accountid");
$userProfileManager = $upm.GetUserProfile($userProfile["Manager"].Value);
$userProfileManager["Name"].Value

Reference: http://social.technet.microsoft.com/wiki/contents/articles/20692.sharepoint-2013-get-set-and-copy-user-profile-properties-using-powershell.aspx

| improve this answer | |
  • Thanks Nagarajan but its not working.I'm getting value cannot be null despite hard coding "company\accountid" – naijacoder Oct 21 '15 at 3:54
  • Tried email address as suggested in the reference but getting error - something wrong with retrieving the user profile – naijacoder Oct 21 '15 at 5:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.