Find AD accounts that are expiring

[sourcecode language=”powershell”]
Search-ADAccount -AccountExpiring -TimeSpan ([TimeSpan]::FromDays(7)) | Select-Object name*,userpri*,accou*
[/sourcecode]
“FromDays(7)” = this will search accounts that are expiring in 7 days
Select-Object name*,userpri*,accou* = this will print a table with account names, UPN and accountexpirationdate

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

fourteen − three =