Get User Profile Property by PowerShell

17/12/2015 01:47

Add-Pssnapin microsoft.sharepoint.powershell -ea 0

$siteUrl = "https://mysitecollectionurl"
$userName = "domain\username"
   
$site = Get-SPSite $siteUrl
$serviceContext = [Microsoft.SharePoint.SPServiceContext]::GetContext($site); 

#Get UserProfileManager from the My Site Host Site context
$profileManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext)
$userProfile = $profileManager.GetUserProfile($userName);  
$userProfile["myPropertyName"]


break;
$userProfile["myPropertyName"].Value = "My property value";
$userProfile.Commit();