Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

what is the syntax to expire an account in AD via Quest Powershell

Posted on 2013-12-03
9
Medium Priority
?
764 Views
Last Modified: 2013-12-03
trying to expire an account via Quest Powershell but the date syntax is not working correctly

Set-QADUser -Identity testuser1 -AccountExpires 2013-12-20

After the script runs, the account gets set to expire but the DAY is off by 2 days....

so it sets to expure on 2013-15-20 instead of 2013-12-20

thoughts?
0
Comment
Question by:ARM2009
  • 4
  • 4
9 Comments
 
LVL 53

Expert Comment

by:Will Szymkowski
ID: 39693129
If you want you can also accomplish this from built in AD. Use the below script.

# Import the Active Directory module if not already loaded
if (-not (Get-Module ActiveDirectory)){
    Import-Module ActiveDirectory -ErrorAction Stop
}

#This section grabs the username you supply, to use in later command
$username = read-host "Please enter the username"

#This section grabs the date/time to use in later command
$expires = read-host "Please enter the time to expire in format [MM/DD/YYYY H:MM:SS PM]"

#This command takes the previous 2 inputs and executes the command.
Set-ADUser $username -AccountExpirationDate "$expires"

# end of script

Open in new window


Reference - http://community.spiceworks.com/scripts/show/1719-set-account-expiration-granular

Will.
0
 
LVL 37

Expert Comment

by:Jamie McKillop
ID: 39693224
Hello,

Set the specific time you want it to expire in this format:

"12/21/2013 12:00:00 AM"

The time is in GMT. If you are in the GMT time zone, this would set the account to expire at the end of 12/20/2013. For example, if you were in the eastern time zone and wanted it to expire at the end of 12/20/2013, you would set it to "12/21/2013 5:00:00 AM"

-JJ
0
 

Author Comment

by:ARM2009
ID: 39693247
i set the following

set-Qaduser -identity username -AccountExpires "12/21/2013 5:00:00 AM"

my result is as follows

in ADUC account shows to expire on

Thursday, December 19, 2013

still seeing that 2 day difference....
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

 
LVL 37

Expert Comment

by:Jamie McKillop
ID: 39693265
Run Get-QADUser -Identity username | select accountexpires

Let me know what value is returned.

-JJ
0
 

Author Comment

by:ARM2009
ID: 39693276
AccountExpires
--------------
12/20/2013 11:00:00 PM

in ADUC

Thursday, December 19, 2013
0
 
LVL 37

Expert Comment

by:Jamie McKillop
ID: 39693286
OK, so your time zone is GMT -6. You would use the time "12/21/2013 6:00:00 AM" to have it expire at the end of 12/20/2013.

-JJ
0
 

Author Comment

by:ARM2009
ID: 39693288
seems like the data

AccountExpires
--------------
12/20/2013 11:00:00 PM

shows correct per the script ("12/21/2013 5:00:00 AM") ... but info in ADUC is not correlating.
0
 
LVL 37

Accepted Solution

by:
Jamie McKillop earned 500 total points
ID: 39693307
The issue here is that when you set the expiration in ADUC, you set "end of" and not a specific time. So, if you set it to 12/20/2013 in ADUC, the value of AccountExpires would be set to 12/21/2013 12:00:00 AM. The ADUC interface will always report the day prior to the actual date set on the attribute because it isn't specific enough to report the exact time. The account will actually expire at the exact time if set using powershell. The other issue is that the time entered in powershell is GMT, so you need to shift for your time zone.

As I said above, if you set the value to "12/21/2013 6:00:00 AM", ADUC will reflect what you want.

-JJ
0
 

Author Comment

by:ARM2009
ID: 39693334
thanks JJ.
0

Featured Post

A Cyber Security RX to Protect Your Organization

Join us on December 13th for a webinar to learn how medical providers can defend against malware with a cyber security "Rx" that supports a healthy technology adoption plan for every healthcare organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Transferring FSMO roles is done when an admin wants to split roles between certain Domain Controllers or the Domain Controller holding the Roles has been forcefully demoted using dcpromo / forceremoval
Exchange administrators are always vigilant about Exchange crashes and disasters that are possible any time. It is quite essential to identify the symptoms of a possible Exchange issue and be prepared with a proper recovery plan. There are multiple…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question