Sometimes we might need to get Sitecore user information in detail. The information might not find in the same place. Different scrips might be handy to extract different information.

Get user id, user domain, and if the user is an admin
Script:

Get-User -Filter "[email protected]*.com"

.

Output:

Name                     Domain       IsAdministrator IsAuthenticated IsEnabled
----                     ------       --------------- --------------- ---------
sitecore\Munir           sitecore     True            False           True

.



Get user roles
Script:

Get-User -Filter "sk\bk_nomedia" | Select-Object -ExpandProperty Roles

.

Output:

Name                                     Domain       IsEveryone
----                                     ------       ----------
sk\tes Exm User                          sk           False
sk\No Media Uploader                     sk           False

.



Get all properties
Script:

Get-User -Filter "sitecore\mu*" | Select-Object -Property *

.

Output:

IsEnabled       : True
Roles           :
MemberOf        :
Delegation      : Sitecore.Security.Accounts.UserDelegation
Domain          : sitecore
IsAdministrator : True
IsAuthenticated : False
LocalName       : Munir
Profile         : Sitecore.Security.UserProfile
RuntimeSettings : Sitecore.SecurityModel.UserRuntimeSettings
Identity        : Sitecore.Security.Principal.SitecoreIdentity
AccountType     : User
Description     : User
DisplayName     : sitecore\Munir
Name            : sitecore\Munir

.



Get user profile details
Script:

Get-User -Filter "sitecore\mu*" | Select-Object -ExpandProperty Profile

.

Output:

ClientLanguage     :
Comment            :
ContentLanguage    :
Culture            : en-US
Email              : [email protected]
FullName           : Munir Hassan
Icon               :
IsAdministrator    : True
LegacyPassword     :
ManagedDomainNames :
Notifications      :
EngagementValue    :
CurrentPosition    :
Badges             :
Name               :
Portrait           : office/16x16/default_user.png
ProfileItemId      : {D54D9A36-11BB-4086-A045-53729AD393FF}
ProfileUser        : Sitecore.Security.Accounts.User
RegionalIsoCode    :
SerializedData     : {[digestcredentialhash, 9f84ad4fdd2bbb7d2f103d0f8e996a49], [digestcredentialhashwithoutdomain, 4114d0930e819d5819b7019539403cbc], [/sitecore\munir/Ribbon/My Strip, {D33A0641-9F1C-4984-8342-0655C3D0F123}],
                     [SpeakComponentStatus-CrossPagesNavigationStatus-1950632152BB4E39ACA3EAEB8E926F78, [{"id":"{9837BB1B-CA0E-4694-B1DB-AE18D2951EA0}"},{"id":"{B9477621-68D4-4152-A7B0-941BCAB68C6B}"}]]...}
StartUrl           :
State              :
UserName           : sitecore\Munir
IsAnonymous        : True
IsDirty            : False
LastActivityDate   : 5/10/2021 11:51:57 AM
LastUpdatedDate    : 1/10/2021 3:54:59 PM
Properties         : {Portrait, Name, StartUrl, Icon...}
Providers          : {disabled, sql, switcher}
PropertyValues     : {ProfileUser, IsAdministrator, Icon, Portrait...}
Context            : {UserName, IsAuthenticated}
IsSynchronized     : False

.



Get user creation date, last login, if the user is locked
Script:

$property = @(
    @{Label="User Name"; Expression={ $_.UserName} },
    @{Label="Email"; Expression={ $_.Email} },
    @{Label="Comment"; Expression={ $_.Comment} },
    @{Label="Locked"; Expression={ $_.IsLockedOut } },
    @{Label="Created"; Expression={ $_.CreationDate} },
    @{Label="Last Login"; Expression={ $_.LastLoginDate} }
    )

[System.Web.Security.Membership]::GetAllUsers() | Where-Object { $_.UserName -like  "sitecore\munir"} |

Select-Object -Property $property 

.

Output:

User Name  : sitecore\Munir
Email      : [email protected]
Comment    :
Locked     : False
Created    : 24/08/2020 5:07:15 AM
Last Login : 5/10/2021 1:44:28 AM

.



Get user is online, last activity and other information
Script:

[System.Web.Security.Membership]::GetAllUsers() | Where-Object { $_.UserName -like  "sitecore\mu*"} |

Select-Object -Property *

.

Output:

Comment                 :
CreationDate            : 24/08/2020 5:07:15 AM
Email                   : [email protected]
InnerUser               : sitecore\Munir
IsApproved              : True
IsLockedOut             : False
LastActivityDate        : 1/10/2021 5:53:14 AM
LastLockoutDate         : 1/01/1754 12:00:00 AM
LastLoginDate           : 1/10/2021 5:53:14 AM
LastPasswordChangedDate : 19/04/2021 5:28:32 AM
PasswordQuestion        :
ProviderName            : sitecore
ProviderUserKey         : 381e39c0-ee0e-45f5-a3ae-d9c9d772363f
UserName                : sitecore\Munir
IsOnline                : True


.



There could be hundreds of users and you may need their information in a CSV
Script:

Get-User -Filter "sitecore\*" | Export-CSV -Path "$apppath\sitecoreUserInfo.csv" -Append -NoTypeInformation
Download-File  "$apppath\sitecoreUserInfo.csv"

.

Output: It will show you a modal to download the CSV


Thanks
Munir

Sitecore EXM Previous post Email dispatch issue – Sitecore EXM

Leave a Reply

Your email address will not be published.