30 C
Dubai
Thursday, November 14, 2024

Modify ADAccountExpiration date for Users in Bulk using CSV Import

Got the CSV in below Format –

EmployeeID Username EndDate
EES01 Ram.shankar 4/6/2016
EES02 Ajay.george 11/28/2016
EES03 Karthick.Kane 5/25/2016
EES04 Vaishika.Sathesh 9/1/2016

 

  • Always change the format to MM/DD/YYYY  – Please verify in your case. (Note : TO change formats in bulk excel is the best choice Choose those columns – Format Cells and choose the type you want)
  • Accounts get expired in a day prior which you specify here.

Like Query for an Existing user who as an existing expiry date . And verify the format.

Get-ADUser -Identity sathesh.manoharan -Properties accountexpirationdate

image

Login to an Domain Controller

Open PowerShell – Run as Administrator

Import-Module ActiveDirectory

TO Check Prior (WHATIF) –  (Note: Shell is pointing to CSV location or change the CSV location like C:\ )

Import-Csv '.\Employees.csv' | foreach {Set-ADAccountExpiration -identity $_.username -Date
Time $_.EndDate -whatif}

TO Change –

Import-Csv '.\Employees.csv' | foreach {Set-ADAccountExpiration -identity $_.username -Date
Time $_.EndDate}
Satheshwaran Manoharan
Satheshwaran Manoharanhttps://www.azure365pro.com
Award-winning Technology Leader with a wealth of experience running large teams and diversified industry exposure in cloud computing. From shipping lines to rolling stocks.In-depth expertise in driving cloud adoption strategies and modernizing systems to cloud native. Specialized in Microsoft Cloud, DevOps, and Microsoft 365 Stack and conducted numerous successful projects worldwide. Also, Acting as a Technical Advisor for various start-ups.

Related Articles

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here

× How can I help you?