[Sitecore Powershell] #2 — Get list of users with filters
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.