Determine LastLogon (last login) of a user in AD using Get-ADUser

Especially for administrators who work in a network with an AD structure (Active Direcotry) it may be desirable if they can query the last login date or the last login time relatively quickly and easily . By default this is not so easy, but the PowerShell brings with it the command

Get-ADUser

the right tool with. In order to access the user’s LastLogon data, you first have to call up a PowerShell console. It is important that this PowerShell Console is run as an administrator , otherwise the following queries will fail.

Then the Active Directory Module must first be loaded into the PowerShell console so that you can also use the Active Directory commands in the PowerShell session. This is done with the command

ActiveDirectory import modules

The module is loaded within seconds. We have shown you the entire process from loading the AD module to querying the “last login data” using an example below.

Last Logon PowerShell

After importing the AD module you can now issue the following command.

Get-ADUser “USERNAME” properties LastLogonDate | FT -Property Name, LastLogonDate -A

As you can see in the example above, this gives you the ” LastLogonDate ” and also the time. For the placeholder ” USERNAME ” you must of course enter the user name that should be queried. The domain name does not necessarily have to be specified in the query.

In the second example we asked for a username that had never logged in, so no result is output.

For example, if you want to have all users with logon data that begin with a special first name, then the command is as follows.

Get-ADUser -Filter {GivenName -eq “Peter”} -Properties LastLogonDate | FT -Property Name, LastLogonDate -A

LastLogon from a user group

You can of course do the same with the last name, then you just have to exchange the file name ” GivenName ” for ” Surname “.

More interesting PowerShell commands can also be found in these articles.


Show file rights with PowerShell – Read WindowsUpdate.log in Windows 10 or reformat with PowerShell – Install
Windows roles and features with PowerShell – Read out
computer system information with PowerShell
– Exchange quotas (quota) settings with PowerShell
– Windows with WINRM Prepare client for remote PowerShell commands
– Edit local users and groups with
PowerShell
– Determine Windows system runtime with PowerShell – Create Windows 10 system restore point with PowerShell

Shut down and restart Windows with PowerShell commands – Repair Windows component stores with DISM and PowerShell commands
– Switch off UAC (user account control) via PowerShell or registry in Windows 10
– PowerShell command to deactivate the firewall

administrator