{"id":1074,"date":"2010-08-27T12:31:43","date_gmt":"2010-08-27T07:01:43","guid":{"rendered":"http:\/\/198.58.113.91\/blog\/?p=1074"},"modified":"2020-10-02T06:27:54","modified_gmt":"2020-10-02T06:27:54","slug":"show-last-logon-date-time-local-users-windows","status":"publish","type":"post","link":"https:\/\/www.winhelponline.com\/blog\/show-last-logon-date-time-local-users-windows\/","title":{"rendered":"How to Find the Last Logon Date\/Time for Local User Accounts in Windows"},"content":{"rendered":"<p>In response to a script request recently from one of our readers, here is an article that tells you how to find the last logged in date and time for all user accounts on the computer.<\/p>\n<p><!--more--><\/p>\n<h2>Find the last login date\/time for all user accounts<\/h2>\n<p><strong>Important:<\/strong> For Windows 10 Microsoft Account (MSA) accounts, the last login information showed by the script, Net command-line, or PowerShell methods below won&#8217;t match the actual last logon time. That&#8217;s because once you switch from a local user account to MSA, Windows won&#8217;t consider it as a local account.<\/p>\n<h3>Method 1: Using a VBScript<\/h3>\n<p>Here is a VBScript that I came up with, that displays the last login date\/time details for each local user account on the computer.<\/p>\n<p>Copy the following lines of code to Notepad, and save the file as <code>last_logon.vbs<\/code><\/p>\n<pre>Option Explicit\r\nDim objWMIService, colItems, WshNetwork, strComputer\r\nDim objUser, objItem, dtmLastLogin, strLogonInfo\r\nSet WshNetwork = CreateObject(\"Wscript.Network\")\r\nstrComputer = WshNetwork.ComputerName\r\n\r\nSet objWMIService = GetObject(\"winmgmts:\\\\\" &amp; strComputer &amp; \"\\root\\cimv2\")\r\nSet colItems = objWMIService.ExecQuery _\r\n(\"Select * from Win32_UserAccount Where Domain = '\" &amp; strComputer &amp; \"'\")\r\n\r\nFor Each objItem in colItems\r\n\tdtmLastLogin = \"\"\r\n\tOn Error Resume Next\r\n\tSet objUser = GetObject(\"WinNT:\/\/\" &amp; strComputer _\r\n    \t&amp; \"\/\" &amp; objItem.Name &amp; \",user\")\r\n\tdtmLastLogin = objUser.lastLogin\r\n\tOn Error Goto 0\r\n\tstrLogonInfo = strLogonInfo &amp; vbCrLf &amp; objItem.Name &amp; \": \" &amp; dtmLastLogin\r\nNext\r\n\r\nMsgBox strLogonInfo, vbOKOnly + vbInformation, \"Last Logon Information for Local Users\"<\/pre>\n<p>Double-click the script to run it. Wait for 30-40 seconds to see the list of user accounts and the corresponding &#8220;last login&#8221; times.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10042\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2010\/08\/last-logon-date-time-windows-vbs.png\" alt=\"last logon date for all user accounts local computer - vbscript\" width=\"313\" height=\"237\" \/><\/p>\n<p><em>This script uses WMI&#8217;s <code>Win32_UserAccount<\/code> class to get the list of local user account information. It queries the <code>LastLogin<\/code> property for each local user account and displays it in a message box.<\/em><\/p>\n<p><em><strong>Tip:<\/strong> If you need to know the last login information of all user accounts at every startup, place the script into your Startup folder. To open the Startup folder of your user profile, press <kbd>Win<\/kbd> + <kbd>R<\/kbd> to access the Run dialog, type <code>shell:startup<\/code> and click OK. Create a shortcut to the VBScript file in the Startup folder.<\/em><\/p>\n<hr \/>\n<h3>Method 2: Using PowerShell<\/h3>\n<p>To find the last login information for all local accounts using PowerShell, run one of the following commands in the PowerShell window:<\/p>\n<pre>Get-LocalUser | Select Name, Lastlogon<\/pre>\n<p>(or)<\/p>\n<pre>$([ADSI]\"WinNT:\/\/$env:COMPUTERNAME\").Children | where {$_.SchemaClassName -eq 'user'} | Select Name, Lastlogin<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10041\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2010\/08\/last-logon-date-time-windows-1.png\" alt=\"last logon date for all user accounts local computer\" width=\"699\" height=\"286\" \/><\/p>\n<hr \/>\n<h3><strong>Method 3: Using the NET USER<\/strong> command-line<\/h3>\n<p>The\u00a0<code>NET USER &lt;USERNAME&gt;<\/code> command shows the last login time of a user account.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10043\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2010\/08\/last-logon-date-time-windows-net-user.png\" alt=\"last logon date for all user accounts local computer - net user\" width=\"699\" height=\"391\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In response to a script request recently from one of our readers, here is an article that tells you how to find the last logged in date and time for all user accounts on the computer.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[7],"tags":[106,396,480],"class_list":["post-1074","post","type-post","status-publish","format-standard","hentry","category-windows","tag-command-prompt","tag-powershell","tag-scripts"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":1666,"url":"https:\/\/www.winhelponline.com\/blog\/cannot-find-script-run-vbs-logon\/","url_meta":{"origin":1074,"position":0},"title":"Fix &#8220;Can not find script file C:\\WINDOWS\\run.vbs&#8221; at Logon","author":"Ramesh","date":"February 20, 2016","format":false,"excerpt":"When you log on to your computer, the error \"Can not find script file C:\\WINDOWS\\run.vbs\" with Windows Script Host in the title is shown on a blank screen with a black background. This happens if malware has modified the Userinit registry value, replacing the Windows default value data with a\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/w10\/run_vbs_err-1.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/w10\/run_vbs_err-1.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/w10\/run_vbs_err-1.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":4017,"url":"https:\/\/www.winhelponline.com\/blog\/hide-email-address-login-screen-windows-10\/","url_meta":{"origin":1074,"position":1},"title":"How to Hide Email Address from Login Screen in Windows 10?","author":"Ramesh","date":"September 5, 2016","format":false,"excerpt":"The Microsoft account email ID is displayed by default in the login screen. To improve your privacy and security, you can hide your MSA email address from the login screen. Here is how to do that in Windows 10 v1607 (Anniversary Update).Remove Email Address from Windows 10 Login ScreenOpen Settings\u2026","rel":"","context":"In &quot;Windows 10&quot;","block_context":{"text":"Windows 10","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/windows-10\/"},"img":{"alt_text":"remove mail address login screen windows 10","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/09\/remove-mail-address-login-screen-0.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/09\/remove-mail-address-login-screen-0.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/09\/remove-mail-address-login-screen-0.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/09\/remove-mail-address-login-screen-0.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":179,"url":"https:\/\/www.winhelponline.com\/blog\/how-to-automatically-login-to-windows-and-then-lock-the-workstation\/","url_meta":{"origin":1074,"position":2},"title":"How to Automatically Login and Auto-Lock Workstation After Login","author":"Ramesh","date":"April 13, 2008","format":false,"excerpt":"Setting up an automatic login in Windows also comes with a great responsibility to safeguard the user account from unauthorized use. After configuring automatic login to your user account, you may also want to set it to lock the workstation immediately at login. Contents Step 1: Setting up Automatic Login\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"auto login and lock scheduler time delay","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2008\/04\/autolock-pc-scheduler-time-delay.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2008\/04\/autolock-pc-scheduler-time-delay.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2008\/04\/autolock-pc-scheduler-time-delay.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2008\/04\/autolock-pc-scheduler-time-delay.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":1839,"url":"https:\/\/www.winhelponline.com\/blog\/create-daily-restore-point-task-scheduler-script\/","url_meta":{"origin":1074,"position":3},"title":"How to Create Automatic System Restore Points Daily in Windows 10\/11","author":"Ramesh","date":"March 5, 2016","format":false,"excerpt":"This post tells you how to schedule the creation of daily System Restore point during startup or logon in all versions of Windows, including Windows 10 and Windows 11. The first method involves a VBScript that I wrote to create restore points, and the 2nd method uses the WMI command-line\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"system restore list of restore points in windows 11 - 24 hrs frequency","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/03\/restore-point-script-rstrui-24-hrs-freq.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/03\/restore-point-script-rstrui-24-hrs-freq.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/03\/restore-point-script-rstrui-24-hrs-freq.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":19346,"url":"https:\/\/www.winhelponline.com\/blog\/duplicate-users-windows-login-screen\/","url_meta":{"origin":1074,"position":4},"title":"[Fix] Duplicate User Accounts in the Windows 10 or 11 Login Screen","author":"Ramesh","date":"October 18, 2020","format":false,"excerpt":"When you start your Windows 10 or 11 computer, the error \"The user name or password is incorrect\" appears. Also, duplicate user accounts may appear on the login screen. The user name or password is incorrect. Try again. After you click the OK button, you're prompted to enter the correct\u2026","rel":"","context":"In &quot;Windows 10&quot;","block_context":{"text":"Windows 10","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/windows-10\/"},"img":{"alt_text":"two user accounts (duplicate) appear at lock screen","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2020\/10\/duplicate-user-accounts-2.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":5719,"url":"https:\/\/www.winhelponline.com\/blog\/username-password-incorrect-every-restart-windows-10\/","url_meta":{"origin":1074,"position":5},"title":"[Windows 10] &#8220;The Username or Password is Incorrect&#8221; Error at Every Restart","author":"Ramesh","date":"October 31, 2017","format":false,"excerpt":"After installing a Feature Update like Fall Creators Update, you may face yet another weird issue. Whenever the computer is restarted, the first screen that may show up even before the login screen is: \"The username or password is incorrect. Try again.\" Note that the above screen shows up even\u2026","rel":"","context":"In &quot;Windows 10&quot;","block_context":{"text":"Windows 10","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/windows-10\/"},"img":{"alt_text":"username or password is incorrect windows 10","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2017\/10\/w10-use-my-signin-info.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2017\/10\/w10-use-my-signin-info.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2017\/10\/w10-use-my-signin-info.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2017\/10\/w10-use-my-signin-info.jpg?resize=700%2C400&ssl=1 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts\/1074","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/comments?post=1074"}],"version-history":[{"count":0,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts\/1074\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/media?parent=1074"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/categories?post=1074"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/tags?post=1074"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}