Outdated or unused accounts provide penetration points that may go undetected. Inactive accounts must be deleted if no longer necessary or, if still required, disabled until needed.
Enter "Search-ADAccount -AccountInactive -UsersOnly -TimeSpan 35.00:00:00"
This will return accounts that have not been logged on to for 35 days, along with various attributes such as the Enabled status and LastLogonDate.
Member servers and standalone or nondomain-joined systems:
Copy or enter the lines below to the PowerShell window and enter. (Entering twice may be required. Do not include the quotes at the beginning and end of the query.)
This will return a list of local accounts with the account name, last logon, and if the account is enabled (True/False). For example: User1 10/31/2015 5:49:56 AM True
Review the list of accounts returned by the above queries to determine the finding validity for each account reported.