Output last logon timestamp


Ever needed to output the last login Timestamp of a particular Active Directory OU to a file?

I needed to do this after inheriting a new secondary school & when upgrading 100s of laptops to Windows 10 and not knowing which ones had recently been logged into!

get-adcomputer -Properties * -SearchBase "OU DISTINGUISHED PATH" -SearchScope Subtree -Filter * | select Name, LastLogonDate | Out-File C:\out\out.txt