Getting Sitecore user profile data can be a headache and some peoples will write long code using dot-net to fetch the User information.In this post, we will explore a great way of extracting user profile data that is a time saver and easily implementable. A simple and no headache way of get the user profile data by domain wise.
The Get-User command returns a user or performs a search to retrieve multiple users from Sitecore. To search for and retrieve more than one user, use the Filter parameter.
Example 1: Fetch top five user with domain as “admin”
##################################################################################################### #Project :Getting Sitecore User Profile Data filter with domain Using Sitecore PowerShell Extensions. #Developer : Thiyagu S (dotnet-helpers.com) #Tools : PowerShell 5.1.15063.1155 & SiteCore 8.1 #E-Mail : mail2thiyaguji@gmail.com ##################################################################################################### $userList = Get-User -Filter * | Where-Object {$_.Domain -eq "admin"} | Select-Object -First 5 $userList
OUTPUT
Example 2: Fetching & counting user profile data
##################################################################################################### #Project : Getting Sitecore User Profile Data filter with domain Using Sitecore PowerShell Extensions. #Developer : Thiyagu S (dotnet-helpers.com) #Tools : PowerShell 5.1.15063.1155 & SiteCore 8.1 #E-Mail : mail2thiyaguji@gmail.com ##################################################################################################### $userList = Get-User -Filter * | Where-Object {$_.Domain -eq "anonymous"} $domainUserCount = 0 foreach ($user in $userList){ $domainUserCount = $userCount+1 } write-host "Total no. of User" $domainUserCount