Active Directory
A set of directory-based technologies included in Windows Server.
6,918 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello everyone,
How can I filter accounts whose user accounts have been closed within this year?
I will search all accounts, if the account is closed within the date range I specified, the information should be written on the screen.Can you help with this issue.
Hi,
You can filter with the AccountExpires property of AD users.
$date =[System.DateTime]"2023-12-31"
Get-ADUser -Filter {AccountExpires -lt $date -and AccountExpires -gt 0} | Select-Object -ExpandProperty Name
Best Regards,
Ian Xue
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.