Domain migrations are in full swing so I thought I would start to share some of the scripts used in the process. This one identifies users that have not logged on in over 180 days. The thought behind this is to find the target population to be migrated. We all have old accounts in our Active Directories. There is no reason to migrate all of those stale accounts so this will help you find them early in your identification stages. This will allow you to disable them and allow for any re-enabling if necessary before the user migration process.
Search-ADAccount -UsersOnly -AccountInactive -TimeSpan 180.00:00:00 | ?{$_.enabled -eq $True} | sort lastlogondate | select-object samaccountname, lastlogondate, name, distinguishedname, enabled | Export-Csv c:\temp\Users180.csv
* Looks at Users older than 180 days within the whole domain, that are not already disabled and outputting samaccountname, lastlogondate, name, distinguishedname, enabled to a CSV file
Hello, this script works, but it actually just list the inactive users, can you please provide me a powershell script that can actually disable the inactive accounts (30) days & also it creates a log file of all inactive users. Please, provide ASAAAAAAP, that be helpful.