We need to clean up users in Active Directory.. One simple step to clean up AD Accounts is to check for the last logon times. If its older then 90 days then disabled the account and move it to the disabled OU
Get-QADUser -Sizelimit 0 |?{ $_.LastLogonTimestamp -lt (get-date).AddDays(-90)} | Select UserPrincipalName | export-Csv "C:\details.csv" $csv = Import-csv -path "C:\details.csv" foreach($user in $csv) { Move-QADObject $User -NewParentContainer "domain.com/Disabled Accounts"Disable-QADUser $user }
Regards,Krishnahttp://smtpport25.wordpress.com
You are missing a "-" in front of Sizelimit
Another thing, are you sure you mean -gt and not -le ?
Yep, Thanks..
Corrected the same, Thanks
Krishna