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
» 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.