• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2831
  • Last Modified:

powershell script to extend the expiration date of user account to april 1st, 2011

Hi All,

I need a powershell script to change the expiration date of user account to april 1st, 2011. we are running 2008 R2 with active directory module loaded.

Pleaes advise.

Thanks
0
fireburn11
Asked:
fireburn11
  • 6
  • 4
  • 3
1 Solution
 
Dale HarrisProfessional Services EngineerCommented:
Try this:

get-qaduser | set-qaduser -oa @{accountExpires = '129462012000000000'}

You must also have the Quest AD CMDlets installed:
http://www.quest.com/powershell/activeroles-server.aspx

HTH,

Dale Harris
0
 
Chris DentPowerShell DeveloperCommented:
You know, Set-QADUser has an -AccountExpires parameter. See:
Get-Help Set-QADUser -Parameter AccountExpires

Open in new window

It should be a bit easier to use than the date string for ObjectAttributes :)

Chris
0
 
Dale HarrisProfessional Services EngineerCommented:
Thanks, Chris.  I didn't know if there was a way to set it easier.  

Dale
0
Evaluating UTMs? Here's what you need to know!

Evaluating a UTM appliance and vendor can prove to be an overwhelming exercise.  How can you make sure that you're getting the security that your organization needs without breaking the bank? Check out our UTM Buyer's Guide for more information on what you should be looking for!

 
fireburn11Author Commented:
thanks guys , but sqduser is only availabe with quest add-in installed, which i dont have...
0
 
Chris DentPowerShell DeveloperCommented:
Ah shame, still, 2008 R2... MS AD Module?

If so:
Import-Module ActiveDirectory

Set-ADUser "UserID" -AccountExpirationDate $(Get-Date "18/02/2011")

Open in new window

Chris
0
 
Dale HarrisProfessional Services EngineerCommented:
Don't you mean:

Import-Module ActiveDirectory

Set-ADUser "UserID" -AccountExpirationDate $(Get-Date "1/04/2011")


?

Also, Fireburn, if you haven't checked out Quest CMDlets, I would really recommend it. :)

DH
0
 
Chris DentPowerShell DeveloperCommented:
Oh yeah, April, missed that bit :)

So yes, that'd be better :)

Chris
0
 
Dale HarrisProfessional Services EngineerCommented:
So, in regards to this question at least, I would say we broke even :)

Dale
0
 
Chris DentPowerShell DeveloperCommented:
lol :)

Chris
0
 
fireburn11Author Commented:
thanks guys. However, instead of doing bulk users which is over 3000 users. I decided to do 20 users at a time just to be safe.
I have put user's samaccountname in a text file,

i need powershell script to read in the text file then do set-aduser -accountexpirationdate "4/1/2011"

Any idea how to do that?

Thanks
0
 
Chris DentPowerShell DeveloperCommented:
Yep, nice and easy:
Get-Content YourFile.txt | ForEach-Object {
  Set-ADUser $_ -AccountExpirationDate $(Get-Date "01/04/2011")
}

Open in new window

Modify date format as appropriate :)

Chris
0
 
fireburn11Author Commented:
Thanks Chris.

question on this line:Set-ADUser $_ -AccountExpirationDate $(Get-Date "01/04/2011")

can i simply do -accountexpirationdate "4/1/2011" or it has to be $(get-date "01/04/2011")?
if so, please explain..
0
 
Chris DentPowerShell DeveloperCommented:

It should take "4/1/2011" and handle it for you.

Chris
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 6
  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now