Here is the situation:

Some users have a real account and a ghost accounts/dummy accounts in same domain but with hyphen in the account name.

For example :

John Adams real account is domain\JA001 and his ghost account is domain\JA001-aa

So when we search in people picker by name it shows both accounts.

Question is how to exclude all users with *-aa to show in people picker?

Any help with PowerShell command will be highly appreciated.

  • Do you mean the People Picker or People Search/User Profiles? Oct 14, 2016 at 12:25
  • It is a People Picker control which searches AD for users
    – Kauser
    Oct 14, 2016 at 12:54
  • OK, I removed the User Profile tag that you set to clarify your question. Oct 14, 2016 at 20:08

2 Answers 2


This is what i ran from the command line to exclude the *-aa accounts and it worked for me:

stsadm -o setproperty -pn peoplepicker-searchadcustomfilter -pv "(!(sAMAccountName=*-aa))" -url https://MyWebApplication.com


How would I do this if I wanted to filter out users from a specific sub-domain? I can use the same command as above I just am not sure what condition to check for?

I would use something like this: stsadm -o setproperty -pn peoplepicker-searchadcustomfilter -pv "(!(<>))" -url https://MyWebApplication.com

where <> needs to be that the userPrincipalName does not contain the sub-domain name.

  • Yes. That should work.
    – Kauser
    Oct 15, 2016 at 13:14
  • How would I set that condition though? Oct 17, 2016 at 17:42
  • How about trying something like this :
    – Kauser
    Oct 17, 2016 at 19:24
  • stsadm -o setproperty -pn peoplepicker-searchadcustomfilter -pv "(!(userPrincipalName=*crescent.org))" -url MyWebApplication.com Assuming crescent.org is the domain you want to exclude
    – Kauser
    Oct 17, 2016 at 19:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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