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 -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.