Monday , April 23 2018

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}

About Satheshwaran Manoharan

Satheshwaran Manoharan is an Microsoft Exchange Server MVP , Publisher of CareExchange.in
Supporting/Deploying/Designing Microsoft Exchange for some years.
Extensive experience on Microsoft Technologies.

Check Also

Installation can’t proceed until all Exchange 2003 Servers are removed

Had to extend schema before installing Exchange 2016 on a Exchange 2010 Server environment. Eventually ...

One comment

  1. Perfect, thanks for posting!

Leave a Reply

Your email address will not be published.