Change Account Expiration Date

I have about 2000 accounts.  Is there a way to do a script to change the account expiration date (accountexpires field) from July 31, 2015 to July 31, 2016 with the Description "Specialist"?  So, I only want to change the account expiration date with the word "Specialist" in the Description field.  If it is not possible to filter by Description, just setup a script to change the account expiration date.

Thanks.

July 13th, 2015 9:08pm

The following PowerShell script retrieves all users with the string "specialist" (not case  sensitive) anywhere in the description attribute, and that have an expiration date before July 31, 2016. This ensure they have an account expiration date. The script then assigns the account expiration date of July 31, 2016:

$Users = Get-ADUser -Filter {(description -Like "*specialist*") -And (AccountExpirationDate -lt "July 31, 2016")}
ForEach ($User In $Users)
{
    Set-ADUser -Identity $_.sAMAccountName -AccountExpirationDate "July 31, 2016"
}

However, I did not test this.
Free Windows Admin Tool Kit Click here and download it now
July 13th, 2015 11:08pm

Please have a look on below given informative resources which might helps you to accomplish this task.

Sets the expiration date for an Active Directory account: https://technet.microsoft.com/en-us/library/ee617256.aspx

You may also take help from this earlier discussed thread having suggested solution to get this job done - Scripts to Set Future Account Expiration Date in Active Directory: https://social.technet.microsoft.com/Forums/scriptcenter/en-US/0bc23ef7-eecb-4718-a6e6-ecc76b07fac6/scripts-to-set-future-account-expiration-date-in-active-directory?forum=ITCG

July 14th, 2015 1:47am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics