How to set expiration date for AD Accounts using PowerShell

The following is a comparison between setting expiration date for AD accounts with Windows PowerShell and ADManager Plus:

Windows PowerShell

Steps to set expiration date AD account using PowerShell:

  • Identify the domain in which you want to manage settings of users
  • Identify the LDAP attributes you need modify.
  • Compile the script.
  • Execute it in Windows PowerShell.

Sample Windows PowerShell script

 Copied
Set-ADAccountExpiration -Identity ScottJohn -DateTime "12/31/2020"
Click to copy entire script

ADManager Plus

To set expiration date for users:

  • Select Modify Bulk Computers -> User Management -> Management.
  • Click the Import button to import a CSV file, with the accountExpires attribute mentioned (provide the desired value in "MM-dd-yyyy" format).
  • Click Update in AD.

Screenshot

Set expiration date for Active Directory accounts using ADManager Plus

» Start 30-day Free Trial

  • We can run this script only from the computers which has Active Directory Domain Services role.
  • With every new user, the script will get longer and complicated.
  • Troubleshooting these scripts requires extensive AD and scripting expertise

ADManager Plus can help you unlock AD users in bulk with just a CSV file in a simple and intuitively designed UI.

Manage AD user settings in bulk with ADManager Plus.

  Get 30-day free trial.
  • Embark on your script-free AD management, reporting, and automation journey with ADManager Plus.
  •  
     
  • By clicking 'Start your free trial now', you agree to processing of personal data according to the Privacy Policy.
  • Thanks
  • Your download should begin automatically in 15 seconds. If not, click here to download manually.

Related Powershell How-to Guides:

The one-stop solution toActive Directory Management and Reporting

Email Download Link