[Sitecore Powershell] #2 — Get list of users with filters

Bernard Lim
Sitecore Series
Published in
1 min readJul 23, 2018

Objective

Get the list of users who are normal users, from the ‘sitecore’ domain and are non-admin users. Filtering manually from the Sitecore User Manager will be tedious and takes you hours, especially if your site is huge. The site I was working had around 60,000 accounts!

Code Excerpt

Code Explanation

  • Start off by getting the user list through Get-User
  • Use -Filter with an asterisk * to retrieve all users. Without -Filter , it will ask for an Identity parameter which if specified, only retrieves a single user, which is not what we want here.
  • Follow it by Where-Object, where here you can specify the user properties as required. As we are looking for ‘sitecore’ only domain as well as non-admin, we access both $_.Domain and $_.IsAdministrator respectively.
  • The last part of the code is a simple for-loop to display each user name.
“Close-up of lines of code on a computer screen” by Ilya Pavlov on Unsplash

--

--

Bernard Lim
Sitecore Series

@thebernardlim. Code. Sitecore. Fitness. Food. Random