Powershell - ad_login_count_export.ps1

$OU = "OU=x,OU=x,OU=x,DC=x,DC=x"
# Hash table of user logon counts.
$Logons = @{ }

# Enumerate every Domain Controller in the domain.
$DCs = Get-ADDomainController -Filter *
ForEach ($DC In $DCs) {
    $Server = $DC.Name
    # Retrieve sAMAccountName and logonCount for all users on this DC.
    $Users = Get-ADUser -SearchBase $OU -filter * -Properties sAMAccountName, title, logonCount -Server $($Server)
    ForEach ($User In $Users) {
        $Name = $User.sAMAccountName
        $Count = $User.logonCount
        If ($Logons.ContainsKey("$Name")) {
            # Sum logon counts.
            $Logons["$Name"] = $Logons["$Name"] + $Count
        }
        Else {
            $Logons.Add("$Name", $Count)
        }
    }
}

$Logons.GetEnumerator() | sort Value