This is one of those random commands that are very rearely usful however when they are needed they are great so if you would like to find out how long since a user last logged in or has been inactive then read on..
There are two ways we can do this. The quick way us..
1) At a domain controller drop to a command prompt. Then enter the below
dsquery user -inactive <NumberOfWeeks> -limit 0 | dsget user -fn -ln -samid >>C:\inactive_users.txt
where <NumberOfWeeks> is integer number. This will output your inactive users to the defined txt file.
2) In Active Directory users and computers, right click ‘Saved Queries’, then New -> New Query.
Give the query a name then select the root you wish to query, click ‘Define Query’ and select Users tab, then select ‘Days Since last logon‘.
Then, when it’s run, right click the completed query and export to csv or whatever you want.