The following is a comparison between obtaining an AD user's last logon report with Windows PowerShell and ADManager Plus:
function Get-ADUsersLastLogon() { $dcs = Get-ADDomainController-Filter {Name -like "*"} $users = Get-ADUser -LDAPFilter
"(&(objectCategory=person)(objectClass=user))" $time = 0 $exportFilePath = "c:\scripts\lastLogon.csv" $columns = "name,username,datetime" Out-File -filepath $exportFilePath
-force -InputObject $columns foreach($user in $users) { foreach($dc in $dcs) { $hostname = $dc.HostName $currentUser =
Get-ADUser $user.SamAccountName |
Get-ADObject -Server $hostname
-Properties lastLogon if($currentUser.LastLogon -gt $time) { $time = $currentUser.LastLogon } } if($time -eq 0){ $row = $user.Name+","+$user.SamAccountName+",Never" } else { $dt = [DateTime]::FromFileTime($time) $row = $user.Name+","+$user.SamAccountName+","+$dt } Out-File -filepath $exportFilePath -append -noclobber
-InputObject $row $time = 0 } } Get-ADUsersLastLogon
Screenshot
Following are the limitations to obtain report of every user's last logon date using native tools like Windows PowerShell:
ADManager Plus will generate the report by automatically scanning all DCs in the domain to retrieve the last logon date of the users with the most recent timestamp in a simple and intuitively designed UI.
For AD User Management
For AD User Reporting
For GPO Management
For Password Management
For AD Group Management
For File Access Management
For AD Computer Management
For Office 365 Management
For Exchange Management