Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Is there a way to list specific user profiles instead all the users? Ex: List all the accounts starting with IT.

It should list all the users with ITUser1,ITUser2, ect....

The following script shows how to retrieve all user profiles. Thanks for any suggestions.

$mySiteUrl = "http://www.bing.com"

#Get site objects and connect to User Profile Manager service
$site = Get-SPSite $mySiteUrl
$context = Get-SPServiceContext $site
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context) 
$profiles = $profileManager.GetEnumerator()

foreach ($up in $profiles) {

}
share|improve this question

1 Answer 1

up vote 5 down vote accepted

You can use the Where cmdlet to filter the users.

$profiles = $profileManager.GetEnumerator() | Where {$_.name -like "IT*"}

Note: This does the filtering after retrieving the full list.

Also

$profiles = $profileManager.GetEnumerator() | Where {$_.MultiloginAccounts -like "domainname\adminID*"}
share|improve this answer
    
Thank you Ryan. I didn't have a chance to try it out until today, and it works. Here are the syntax: profiles = $profileManager.GetEnumerator() | Where {$_.MultiloginAccounts -like "domainname\adminID*"} – –  user751119 Apr 18 '13 at 16:53
    
Your welcome, I'll add that to the answer. Please mark it as the correct answer (click the check) since it resolved your issue. –  Ryan Erickson Apr 18 '13 at 17:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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