Dormant accounts
In Active Directory, at least 10% of user accounts are dormant (inactive) accounts. These accounts can represent:
- Test accounts
- Contractors
- Former employees
- Disabled accounts
It is important to review these dormant accounts periodically and remove all unnecessary accounts from Active Directory as they are a possible security threat. If it is not possible to remove some of these accounts, at least remove them from sensitive groups and disable the accounts.
We can find these accounts in Active Directory by looking at the LastLogonDate
attribute value and the account status. By considering these requirements, I created the following script to find dormant accounts:
## Dormant Accounts ##
$InactiveDate = (Get-Date).Adddays(-30)
$HTML=@"
<title>Dormant Accounts Report</title>
<style>
BODY{background-color :LightBlue}
</style>
"@
$disabledaccounts = Get-ADUser -Filter {Enabled -eq $false} ...