SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 9 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
    
can you use use an arry – westerdaled Jun 16 '15 at 11: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.