Skip to content

Get-ADUserLastLogonDate

SYNOPSIS

Retrieves the last logon date of an Active Directory user.

SYNTAX

Get-ADUserLastLogonDate [-Identity] <String> [<CommonParameters>]

DESCRIPTION

The `Get-ADUserLastLogonDate` function retrieves the most recent logon date of an Active Directory user by querying all available domain controllers. It ensures accurate results by comparing the `LastLogon` attribute across all domain controllers.

EXAMPLES

EXAMPLE 1

Get-ADUserLastLogonDate -Identity "jdoe"

Retrieves the most recent logon date for the user "jdoe" by querying all domain controllers.

EXAMPLE 2

Get-ADUserLastLogonDate -Identity "CN=John Doe,OU=Users,DC=example,DC=com"

Retrieves the most recent logon date for the user "John Doe" using their distinguished name.

PARAMETERS

-Identity

The identity of the Active Directory user (e.g., DistinguishedName, UserPrincipalName, or SamAccountName).

Type: String
Parameter Sets: (All)
Aliases: DN, DistinguishedName, UserPrincipalName, UPN, sAMAccountName

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

NOTES