PowerShell Script get Active Directory objects that are Expired and delete them
import-module activedirectory
$ADO = Search-ADAccount -AccountExpired
foreach($object in $ADO)
{
Remove-ADObject -Identity $object.DistinguishedName -Confirm:$false
}
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
import-module activedirectory
$ADO = Search-ADAccount -AccountExpired
foreach($object in $ADO)
{
Remove-ADObject -Identity $object.DistinguishedName -Confirm:$false
}