I am trying to list all accounts that have not been logged into outside of 6 months.
This is my first time really using powershell and I am simply editing other people's scripts at this point to fit my own needs.
I want to separate the search into two lists : computers only and users only.
Code for computers outside six months.
Search-ADAccount -accountinactive -computersonly | where {$_.lastlogondate -lt (get-date).addmonths(-6)} | FT Name,LastLogonDate
Code for users outside six months.
Search-ADAccount -accountinactive -usersonly | where {$_.lastlogondate -lt (get-date).addmonths(-6)} | FT Name,LastLogonDate
However, these are not working and are just spitting out all accounts. I have also noticed changing the -6 to any number really has no effect. Suggestions?