Wednesday, February 3, 2010

How to loop through user profiles in SharePoint 2010 and get a specific property

$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
  $myprop= $userProfile["MypropertyName"]
  Write-Host "$name;$myprop"
}

No comments:

Post a Comment

About