Today we are going to learn how to remove an AD User which is not Active since a long time lets say 1 year. As a part of Server hardening best practices, you should always run checks to remove the disabled or orphan accounts from Active directory.
We will be using the Active Directory module in Powershell to perform the activity :
Get-ADUser -Filter 'LastLogondate -le $Date' -Properties LastLogonDate |
Select Name, LastLogonDate