Having an SharePoint 2010 installation I try to filter the return result of Get-SPUser but I don't see any possible ways to get a single user or filtered users back.

Get-SPUser -Web https://intranet.mysite.com -Limit '30'

Is it possible to use another Get-User method to return only those SPUsers who match search criterion, such as AD\an*

Get-SPUser -web https://intranet.mysite.com | Where-Object {$_.UserLogin -like "*AD\an*"}

For more info on Where-Object: Using the Where-Object Cmdlet

$user=Get-SPUser -Web "you site url" -Limit "All"|Where-Object{$_.Name -match ("sptestuser")}
Write-Host ("User id:"+$user.ID+"  Display name:"+$user.DisplayName+"  Login name:"+$user.LoginName)

The above script get the user from the site with user name:sptestuser

  • Robert's code helped me with a p.i.t.a problem i had where i couldn't tell if my SP 2013 farm knew about certain User Groups. Plugged in my info and it tole me the id and other info i needed to proceed with powershell. thanks – Carp Sep 7 '16 at 22:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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