Sitecore Powershell: Find users last login?


I’m writing a very simple Sitecore PowerShell script to report on all users in our system. We’d like to know the last login date for each user, but I’ve had no luck getting at it. I can access $_.Profile.LastActivityDate, but that doesn’t help as it appears it’s the same value for all users. Any ideas what the expression is to access the last login date, or how I can find it? Thanks.


Get-User will output one or more Sitecore.Security.Accounts.User, whose Profile property is a Sitecore.Security.UserProfile which inherits from System.Web.Profile.ProfileBase. So, the LastActivityDate property should be the same as you’d get by accessing the profile outside of Sitecore.

That said, there is a chance that simply accessing the profile data will update the last activity date.

The LastActivityDate for a user is updated by the classes in the
System.Web.Profile and the System.Web.UI.WebControls.WebParts
namespaces whenever user data is retrieved from or set at the data
source. …

So, you may be able to avoid accessing the profile, and instead, retrieve MembershipUsers. MembershipUser has a property named LastLoginDate which I think is what you’re after:

If you need access to the profile without updating the last activity date, you might also try:


Sitecore Powershell: Find users last login? by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply