Solved

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

Posted on 2013-12-03
9
536 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
 
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
Do email signature updates give you a headache?

Do you feel like you are constantly making changes to email signatures? Are the images not formatting how you want them to? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today.

 

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 125 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
We are happy to announce a brand new addition to our line of acclaimed email signature management products – CodeTwo Email Signatures for Office 365.
In this video we show how to create a Distribution Group in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >>…
To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now