Share via


Active Directory: Bulk modify account expiry

In Active Directory we need to bulk modify the AD attribute.Now I will change the account expiration of AD account using Powershell.

We can check the AD account expiry using following command.

Get-aduser -id <username> -Properties * |fl name,accountexpirationdate

e.g Get-aduser -id adtest2 -Properties * |fl name,accountexpirationdate

Steps:

1. Create new text file and place all user account in it.

I have added two account and save this ad.txt.

2. Open powershell and run below mention command.

Mention the desired expiry date.

Get-Content D:\ad.txt | Set-ADAccountExpiration -DateTime "10/30/2017"

3. Check the result

Using the below mention command.

Get-aduser -id <username> -Properties * |fl name,accountexpirationdate