I need to delete AD users based on expiry date greater than 30 days
I can pull the users that are expired and their expiry date easy enough:
$Today = (Get-Date).ToString("dd-MM-yyyy")
$DeleteDate = (Get-Date $date).AddDays(-30).ToString("yyyyMMdd")
Get-ADUser -Filter 'enabled -eq $false' -Properties AccountExpirationDate | Select sAMAccountName, AccountExpirationDate
But I want to delete only those where the AccountExpirationDate is > 30 days.
Could someone pls help me with an expression to do this?
note my PS skill is rudimentary so simpler is better
Thanks