Active Directory Timestamp Converter (FILETIME / LDAP Int64)
Decode and encode Active Directory time formats in one place — lastLogonTimestamp, lastLogon, pwdLastSet, accountExpires, lockoutTime, Generalized Time (whenCreated), and negative interval values like maxPwdAge. Auto-detects the syntax, handles Microsoft “never” sentinels, and generates PSScriptAnalyzer-compliant PowerShell and LDAP filters.
| Representation | Value | Use It For | Action |
|---|
Active Directory stores time in three distinct syntaxes. Large Integer values count 100-nanosecond ticks since 1601-01-01 UTC (Windows FILETIME). Generalized Time is an LDAP string representation. Domain policy intervals are negative tick counts. Whether an attribute replicates determines which DC must be queried.
| Attribute | Syntax | Replication | Meaning | Special Values / Gotchas |
|---|---|---|---|---|
| lastLogon | Large Integer | Per-DC | Last logon authenticated by that specific DC | Not replicated — query every DC in the domain and take the highest value. 0 indicates no logon on that DC. |
| lastLogonTimestamp | Large Integer | Replicated | Approximate last logon, synchronized domain-wide | Only updated when older than msDS-LogonTimeSyncInterval (default 14 days) minus a random 0–5 day delta → can lag 9–14 days. Ideal for stale-account reports. |
| pwdLastSet | Large Integer | Replicated | Last password change instant | 0 = user must change password at next logon. Writing -1 stamps current time and clears the flag. Only 0 and -1 are writable. |
| accountExpires | Large Integer | Replicated | Account expiration instant | 0 or 9223372036854775807 (0x7FFFFFFFFFFFFFFF) = never. ADUC “End of 15 Jan” stores 16 Jan 00:00 local time converted to UTC. |
| badPasswordTime | Large Integer | Per-DC | Last bad password attempt on this DC | Not replicated. Correlate with badPwdCount and PDC Emulator Security Event 4771/4740. |
| lockoutTime | Large Integer | Replicated | Instant the account was locked | 0 = not locked. A non-zero value persists after unlock unless reset; check if elapsed time exceeds lockoutDuration. |
| msDS-UserPasswordExpiryTimeComputed | Large Integer | Constructed | Calculated password expiry (honours PSOs) | 0x7FFFFFFFFFFFFFFF = never expires. Constructed dynamically by the DC — cannot be filtered in an LDAP query. |
| whenCreated | Generalized Time | Replicated | Object creation timestamp | Format yyyyMMddHHmmss.0Z. Filter in LDAP as (whenCreated>=20260101000000.0Z). |
| whenChanged | Generalized Time | Per-DC | Last change written on that specific DC | Not replicated — differs between replication partners. Use repadmin /showobjmeta for per-attribute history. |
| maxPwdAge / minPwdAge | Interval (Int64) | Domain head | Default domain password policy | Stored as negative 100-ns ticks. -9223372036854775808 = never expires (GPO value 0). |
| lockoutDuration / lockOutObservationWindow | Interval (Int64) | Domain head | Account lockout policy durations | Stored as negative 100-ns ticks. lockoutDuration -9223372036854775808 = locked until an administrator unlocks. |
LDAP filters require the raw Int64 tick value, not a date string. Set a staleness window below and the threshold is computed live, then populated across all snippets. All code follows strict PSScriptAnalyzer rules (PascalCase cmdlets, no aliases, -ErrorAction Stop) and is verified against homelab domain corp.karanth.ovh.
0 to indicate “not set” or “never”. Converting 0 directly evaluates to the Windows FILETIME epoch: 1 January 1601 00:00:00 UTC.0 before converting: if ($v -gt 0) { [DateTime]::FromFileTimeUtc($v) } else { 'Never' }C:\> w32tm /ntte 0
1601-01-01 00:00:00.0000000 – 1/1/1601 12:00:00 AM (UTC)
accountExpires and msDS-UserPasswordExpiryTimeComputed use the maximum signed 64-bit integer (9223372036854775807) to represent an account that never expires. Converted literally, it resolves to 14 September 30828.0 and 9223372036854775807 as “Never” in reporting scripts.C:\> w32tm /ntte 9223372036854775807
30828-09-14 02:48:05.4775807 – 9/14/30828 2:48:05 AM (UTC)
lastLogonTimestamp if the stored value is older than msDS-LogonTimeSyncInterval (default 14 days) minus a randomized 0–5 day delta.lastLogonTimestamp exclusively for stale-account sweeps (>14 days). For real-time forensics, query lastLogon on all DCs or collect Security Event 4624 / 4768 from the PDC Emulator.TargetUserName: skaranth • LogonType: 3 (Network)
TargetDomainName: CORP • Computer: DC01.corp.karanth.ovh
accountExpires.Set-ADAccountExpiration -Identity 'skaranth' -DateTime '2026-01-15 18:00:00Z'.Account Name: skaranth • Account Expires: 2026-01-16 00:00:00 UTC
Caller: Administrator@corp.karanth.ovh
[DateTime]::FromFileTime() converts to the local time zone of the executing server. FromFileTimeUtc() preserves the authoritative UTC representation. Multi-region audits will show time shifts if local conversion is used.FromFileTimeUtc() across all reporting pipelines and convert to regional offsets only at final UI rendering.[DateTime]::FromFileTime(133990000000000000) # Shifts by host offset
[DateTime]::FromFileTimeUtc(133990000000000000) # 2025-08-20 04:53:20Z (Authoritative)
msDS-UserPasswordExpiryTimeComputed is computed dynamically by the directory service upon read request. Domain Controllers do not evaluate constructed attributes inside LDAP search filters.-Properties 'msDS-UserPasswordExpiryTimeComputed' and evaluate with Where-Object.Filter: (msDS-UserPasswordExpiryTimeComputed<=133990000000000000)
Result: 0 matched (Constructed attribute filter ignored by DSA)
[TimeSpan]::FromTicks([Math]::Abs($val)) or read the decoded policy with Get-ADDefaultDomainPasswordPolicy.PS> (Get-ADDefaultDomainPasswordPolicy).MaxPasswordAge
Days: 42, Hours: 0, Minutes: 0, Seconds: 0
lockoutTime records when the account was locked, but does not identify the workstation causing the bad password attempts.DC01.corp.karanth.ovh to identify the CallerComputerName.TargetUserName: svc-backup • CallerComputerName: \\WSRV-TEST
SubjectDomainName: CORP • FailureCode: 0xC0000234
Frequently Asked Questions
How do I convert lastLogonTimestamp to a human-readable date?
lastLogonTimestamp is a Windows FILETIME structure counting 100-nanosecond intervals since 1 January 1601 UTC. In PowerShell run [DateTime]::FromFileTimeUtc(133990000000000000). On any Windows command prompt run w32tm /ntte 133990000000000000.
What does pwdLastSet = 0 mean in Active Directory?
A value of 0 means the user must change their password at the next interactive logon. It is the only value besides -1 that can be written to the attribute manually. Writing -1 stamps the current UTC time, clearing the required change flag.
Why does accountExpires show 9223372036854775807?
9223372036854775807 (0x7FFFFFFFFFFFFFFF) is the maximum signed 64-bit integer. Active Directory uses this sentinel value, alongside 0, to represent an account that never expires. Do not convert this sentinel value to a date in audit reports.
What is the operational difference between lastLogon and lastLogonTimestamp?
lastLogon is exact but stored exclusively on the domain controller that processed the authentication request. lastLogonTimestamp replicates across all domain controllers in the domain, but is only updated when the stored value is older than msDS-LogonTimeSyncInterval (default 14 days, minus random 0–5 days).
How do I find inactive Active Directory accounts using an LDAP filter?
Calculate the FILETIME tick threshold for “current time minus N days” and filter with (lastLogonTimestamp<=THRESHOLD_TICKS). The PowerShell tab above automatically calculates this live threshold and generates ready-to-run queries.
// All calculations execute locally in your browser using native JavaScript BigInt arithmetic (100-ns precision). Zero telemetry or input values leave your browser.