find username closed between specified date

Alper GÜNER 0 Reputation points
2023-09-18T09:31:18.3733333+00:00

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.

Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
6,244 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ian Xue (Shanghai Wicresoft Co., Ltd.) 34,271 Reputation points Microsoft Vendor
    2023-09-25T08:38:32.4033333+00:00

    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.

    0 comments No comments