I have been tasked with cleaning up users in our domain. I have some Powershell experience, but am kind of stuck. I have the first part of a script that returns the users in a particular OU that have lastlogondate and passwordlastset attributes of 360 days or greater. I have created a variable called $user that contains all the information returned in the first part of the script. I now need to, using a foreach loop I assume, disable these accounts and move them to a specific OU in our AD. I have included the script I have so far below. Any advice on this would be greatly appreciated.
$Days=(get-date).adddays(-360)
$user
=Get-ADUser-SearchBase"OU=Customers,DC=OPI,DC=LOCAL"-filter{(lastlogondate-notlike"*"-ORlastlogondate-le$Days)-AND(passwordlastset-le$Days)-AND(enabled-eq$True)}-Propertieslastlogondate,passwordlastset|Select-Objectname,lastlogondate,passwordlastset
$user
|ft-autosize
foreach
($uin$user){
Thank you!