fireburn11
asked on
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
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
You know, Set-QADUser has an -AccountExpires parameter. See:
Chris
Get-Help Set-QADUser -Parameter AccountExpires
It should be a bit easier to use than the date string for ObjectAttributes :)Chris
Thanks, Chris. I didn't know if there was a way to set it easier.
Dale
Dale
ASKER
thanks guys , but sqduser is only availabe with quest add-in installed, which i dont have...
Ah shame, still, 2008 R2... MS AD Module?
If so:
If so:
Import-Module ActiveDirectory
Set-ADUser "UserID" -AccountExpirationDate $(Get-Date "18/02/2011")
Chris
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
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
Oh yeah, April, missed that bit :)
So yes, that'd be better :)
Chris
So yes, that'd be better :)
Chris
So, in regards to this question at least, I would say we broke even :)
Dale
Dale
lol :)
Chris
Chris
ASKER
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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..
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..
It should take "4/1/2011" and handle it for you.
Chris
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