Monday, June 4, 2012

Powershell: Get the list of users that use my custom property

Continue the series of post about powershell and SharePoint.

Here there is another “code draft” usefull to get the list of users that use your custom property:

$url = "http://mysharepointsite/"

$site = Get-SPSite $url

$context = Get-SPServiceContext $site

$pMgr = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)

$enum = $pMgr.GetEnumerator()

while ($enum.MoveNext()) {
$currUser = $profiles.Current
$name = $currUser.DisplayName
$customProp = $currUser["MyCustomProperty"]
Write-Host "$name;$customProp"


No comments:

Post a Comment