26.3 C
Dubai
Friday, December 2, 2022

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
Specialized in Microsoft Azure - Office 365 / Microsoft Exchange; conducted numerous projects worldwide in designing, supporting, and implementing messaging and virtualization infrastructure for medium-sized and large enterprises. Further, I am a Cloud Architect and 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?