Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

AD User report with LastLogon for every DC

$
0
0

Hi

I have a script i use to get user information for all users. The problem is that this customer has multiple DC's. Any ideas how i can get all lastLogon for each DC in the report?

[CmdLetBinding()]
Param(
    [Parameter(Mandatory=$false)]$UserFilter = "*",
    [Parameter(Mandatory=$false)][switch]$ToScreen
)
BEGIN{}
PROCESS{
    $output = Get-ADUser -Filter $UserFilter -Properties DisplayName,Enabled,EmailAddress,DistinguishedName,CanonicalName,Created,msExchWhenMailboxCreated,LastLogonDate,PasswordLastSet,PasswordNeverExpires,LastLogon | select DisplayName,Enabled,EmailAddress,DistinguishedName,CanonicalName,Created,msExchWhenMailboxCreated,LastLogonDate,PasswordLastSet,PasswordNeverExpires,@{e={[datetime]::FromFileTime($_.LastLogon)};l="LastLogon"}
}
END{
    if ($ToScreen) {
        $output | ft DisplayName,Enabled,EmailAddress,DistinguishedName,CanonicalName,Created,msExchWhenMailboxCreated,LastLogonDate,PasswordLastSet,PasswordNeverExpires,LastLogon
    } else {
        $output | Export-Csv -Path .\UserExport.csv
    }
}



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>