I no longer have an AD to work with, but see if the script in the attachment works for you.
checking all on-premise DCs for last logon of csv list of users
Hi all,
I hope all is well wherever you may be
I have been asked to check the last logon of around a thousand accounts, now listed in a csv. I can run
Import-csv "d:\temp\path_to.csv" |foreach-object {get-aduser $_.samaccountname -Properties lastlogondate} |select name,Lastlogon |Export-csv d:\temp\output\LastLogon.csv -NoTypeInformation
But know this only checks 1 DC. I need to check this against all DC's for completeness :)
so something like Get-ADDomainController -filter * would hopefully work but unfortunately PS doesn't like this and I can;t see where/how to complete the PS script.
As this seems the wrong command, could someone let me know what would be the correct one please
thank you :)