Support
 
Phone Live Chat
 
Support
 
US: +1 888 720 9500
 
Intl: +1 925 924 9500
Aus: +1 800 631 268
UK: 0800 028 6590
CN: +86 400 660 8680

Direct Inward Dialing: +1 408 916 9393

 
 
 
 
 

How to get computer lastLogonTimestamp in Active Directory

Active Directory tracks a computer's last authentication in three attributes: lastLogon (accurate but stored per DC), lastLogonTimestamp (replicated domain-wide, updated every 9 to 14 days), and LastLogonDate (its readable DateTime form). For domain-wide queries, lastLogonTimestamp is the reliable choice.

This guide shows how to retrieve it using Get-ADComputer in PowerShell, Active Directory Users and Computers (ADUC), and ADManager Plus.

 
  • PowerShell
  • ADUC
  • ADManager Plus
  • Troubleshooting
  • Why ADManager Plus
  • FAQ
 

Get computer lastLogonTimestamp using PowerShell

Prerequisites for getting computer lastLogonTimestamp via PowerShell

  • Permissions: The account must have at least read access to computer objects in the domain. Domain Admins and accounts with delegated read rights for the target OU both satisfy this requirement.
  • Tools: Install Remote Server Administration Tools (RSAT) on Windows 10 or 11 to get the Active Directory module for Windows PowerShell. On domain controllers, the module is available by default.
  • Module: Import the module before running any command:
    Import-Module ActiveDirectory

Steps to get computer lastLogonTimestamp using PowerShell

  1. Open Windows PowerShell.
  2. Import the Active Directory module:
    Import-Module ActiveDirectory
  3. Run the following command to retrieve LastLogonDate—the readable DateTime form of lastLogonTimestamp—for all computer accounts in the domain:
    Get-ADComputer -Filter * -Properties LastLogonDate |
        Select-Object Name, LastLogonDate
  4. Review the output. Computer accounts with a null LastLogonDate have either never authenticated against a domain controller or have not yet had their lastLogonTimestamp attribute populated.

Query computers in a specific OU

Use -SearchBase to scope the query to a single organizational unit instead of the entire domain:

Get-ADComputer -Filter * -SearchBase "OU=Workstations,DC=corp,DC=com" `
    -Properties LastLogonDate | Select-Object Name, LastLogonDate

Filter computers inactive for 90 days

Assign a 90-day cutoff date to a variable, then pass it to -Filter to return only computer accounts that have not authenticated since that date:

$cutoff = (Get-Date).AddDays(-90)
Get-ADComputer -Filter {LastLogonDate -lt $cutoff} `
    -Properties LastLogonDate, DistinguishedName | Select-Object Name, LastLogonDate, DistinguishedName

Export computer last logon data to CSV

Pipe the results to Export-Csv to produce a flat file for auditing or compliance review:

Get-ADComputer -Filter * -Properties LastLogonDate, OperatingSystem | Select-Object Name, LastLogonDate, OperatingSystem | Export-Csv -Path "C:\Reports\ComputerLastLogon.csv" -NoTypeInformation

Supported parameters: Get-ADComputer

Parameter Description
-Filter Filters which computers are returned. Use * for all computers, or a logical expression such as {LastLogonDate -lt $cutoff} for date-based filtering.
-Properties Specifies additional attributes to retrieve alongside the default set. Use LastLogonDate for a readable DateTime value or lastLogonTimestamp for the raw 64-bit integer.
-Identity Returns a single computer account by SAM account name, distinguished name, SID, or GUID.
-SearchBase Restricts the search to a specific OU or container by distinguished name.
-SearchScope Controls search depth relative to -SearchBase: Base, OneLevel, or Subtree (default).
-Server Targets a specific domain controller instead of the one selected by default.

Limitations for getting computer lastLogonTimestamp via PowerShell

  • lastLogonTimestamp replicates every nine to 14 days, so LastLogonDate can be up to two weeks behind the actual last authentication time.
  • Getting a precise last authentication time requires querying lastLogon on every domain controller individually, since that attribute is not replicated.
  • Running Get-ADComputer -Filter * without -SearchBase against a large domain retrieves every computer account and can be slow.
  • Get-ADComputer is not available without RSAT or the AD DS role installed; every machine running the script must have the Active Directory module present.
  • The inactivity threshold, search scope, and output format are hardcoded per script run; changing any of them requires editing and re-running the script.

Getting computer lastLogonTimestamp using ADUC

Prerequisites for getting computer lastLogonTimestamp via ADUC

  • Permissions: Have Domain Admin rights or delegated read access to computer objects in the target OU.
  • Tools: ADUC is included with RSAT on Windows 10 and 11 and is available by default on domain controllers.
  • Advanced Features: The Attribute Editor tab required to view lastLogonTimestamp appears only when View > Advanced Features is enabled in ADUC. Enable it before proceeding.

Steps to get computer lastLogonTimestamp using ADUC

  1. Open ADUC by running dsa.msc the Run dialog (Win+R)..
  2. Enable View > Advanced Features if it is not already on. This adds the Attribute Editor tab to the Properties dialog for all objects.
  3. Locate the target computer account in the console tree. Use Action > Find (Ctrl+F) to search by computer name if the directory is large.
  4. Right-click the computer account and select Properties.
  5. Open the Attribute Editor tab.
  6. Scroll through the attribute list to lastLogonTimestamp. The column displays a raw 64-bit integer in Windows file time format.
Note:

ADUC does not convert lastLogonTimestamp to a readable date in the Attribute Editor. To interpret the raw value, run the following in PowerShell after substituting the integer:

[DateTime]::FromFileTime(<integer_value>)

Limitations for getting computer lastLogonTimestamp via ADUC

  • ADUC displays lastLogonTimestamp for one computer account at a time; there is no built-in view to list or compare the attribute across multiple accounts.
  • The value shown in the Attribute Editor is a raw 64-bit integer, not a readable date; external conversion is required.
  • ADUC provides no way to filter computers by inactivity threshold or export last logon data in bulk.

Steps to get computer's last logon time using ADManager Plus

Prerequisites for getting computer last logon time via ADManager Plus

  • Permissions: Have an ADManager Plus account with access to the Reports module.
  • Setup: ADManager Plus must be installed and configured with the target domain and all its domain controllers.

All Computers report

  1. Log in to ADManager Plus and navigate to Reports > Computer Reports > General Reports.
  2. Click All Computers.
  3. Select the Domain from the drop-down. To scope the report to a specific OU, select it within the domain.
  4. Click Generate. ADManager Plus lists all computer accounts in the domain with their last logon date included.
  5. To save the report, click Export and choose CSV, PDF, XLSX, or HTML.

Inactive Computers report

  1. Navigate to AD Reports > Computer Reports > Account Status Reports.
  2. Click Inactive Computers.
  3. Select the required Domain and OUs.
  4. Specify the inactivity period. Options include last 30, 60, or 90 days, before a specific date, or a custom range.
  5. To control how inactivity is determined, click More Options. Selecting Last Logon Time causes ADManager Plus to query lastLogon from all configured domain controllers, which gives the most accurate result. Selecting Password Last Set queries only the PDC.
  6. Click Generate.
  7. From the results, you can disable, move, delete, or enable selected computers directly from the report without leaving the console.

Troubleshooting

The Active Directory module is not loaded or RSAT is not installed on the machine running the script. Install the RSAT Active Directory Domain Services and Lightweight Directory Services Tools component for your Windows version, then run Import-Module ActiveDirectory and retry the command.

A null LastLogonDate means lastLogonTimestamp has not been set for the account. This is expected for computer accounts that were added to the domain but have never completed a Kerberos authentication, or for accounts created before lastLogonTimestamp was introduced in Windows Server 2003 SP1. Confirm the account is enabled and has been used to sign in to a domain-joined device.

This is expected behavior. lastLogonTimestamp does not update at every logon; Active Directory updates it only when the elapsed time since the last stored value exceeds nine to 14 days. The value is accurate enough to identify accounts inactive over weeks or months, but not for day-level precision. If you need the most recent authentication time, query lastLogon on each domain controller individually.

Passing a calculated expression directly inside the filter braces can fail to evaluate correctly in some module versions. Assign the cutoff date to a variable first:

$cutoff = (Get-Date).AddDays(-90)
Get-ADComputer -Filter {LastLogonDate -lt $cutoff} -Properties LastLogonDate

Verify that the account has read rights for computer objects in the target OU, that the machine can reach a domain controller, and that the correct domain is being targeted. Use -Server to specify a domain controller explicitly if the default selection is resolving incorrectly.

How ADManager Plus streamlines computer lastLogonTimestamp reporting

  • Computer reports: Generate prebuilt reports listing all computer accounts and their last logon dates without PowerShell, with built-in filters for scope and account status.
  • Inactive Computers report: Run a report that queries lastLogon from all configured domain controllers when the Last Logon Time option is selected, returning computers inactive beyond the threshold you set, with the option to disable, move, or delete stale accounts directly from the results.
  • AD Last Logon reports: Access a dedicated last logon reporting section covering both users and computers, with data sourced from all domain controllers for domain-wide accuracy.
  • Report scheduling: Schedule computer last logon reports to run on a recurring basis and auto-email the results, removing the need to re-run scripts manually.
  • Active Directory cleanup: Pair inactive computer reports with bulk management actions to disable or remove stale accounts as part of a regular Active Directory hygiene workflow.

FAQ

lastLogon updates at every authentication but is stored only on the authenticating domain controller and is not replicated, so querying a single DC gives an incomplete view of the domain. lastLogonTimestamp replicates across all domain controllers but updates only every nine to 14 days, making it reliable for identifying inactive accounts over longer windows. LastLogonDate is the DateTime representation of lastLogonTimestamp that the Active Directory PowerShell module exposes; it holds the same value in a readable format. For domain-wide inactive computer queries, lastLogonTimestamp or LastLogonDate is the correct attribute to use.

Assign the cutoff date to a variable and pass it to -Filter:

$cutoff = (Get-Date).AddDays(-90)
Get-ADComputer -Filter {LastLogonDate -lt $cutoff} `
    -Properties LastLogonDate, DistinguishedName | Select-Object Name, LastLogonDate, DistinguishedName

In ADManager Plus, the Inactive Computers report offers last 30-, 60-, and 90-day presets. With the Last Logon Time option selected, it queries lastLogon from all domain controllers, which is more precise than the replicated lastLogonTimestamp that PowerShell uses.

By design, lastLogonTimestamp does not update at every logon. Active Directory updates it only when the time elapsed since the last stored value exceeds a threshold of nine to 14 days, which limits replication traffic across domain controllers. The attribute is accurate enough to flag accounts inactive over weeks or months, but not for same-day precision.

Yes. Add -SearchBase with the OU's distinguished name to restrict the query:

Get-ADComputer -Filter * -SearchBase "OU=Workstations,DC=corp,DC=com" `
    -Properties LastLogonDate | Select-Object Name, LastLogonDate

In ADManager Plus, the Computer Reports module supports OU-scoped filtering through the GUI without scripting.

Request lastLogonTimestamp in the -Properties list:

Get-ADComputer -Identity "PC01" -Properties lastLogonTimestamp | Select-Object Name, lastLogonTimestamp

To convert the raw 64-bit integer to a readable date:

[DateTime]::FromFileTime($computer.lastLogonTimestamp)

where $computer is the object returned by Get-ADComputer.

ADManager Plus Trusted By

The one-stop solution to Active Directory Management and Reporting