Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Query for expired certs to CA shows datetime as +6 hours off for notbefore,notafter date.

$
0
0

I am having a problem obtaining the list of expired certs from the previous month. When I query my CA the returned value for NotBefore and NotAfter is +6 hours from the actual time as displayed in the certificate Authority MMC.

I am writing a script to obtain metric information from my CA. I am using the following to obtain the previous month's First and last day:

$lastmonth = (get-date).AddMonths(-1).DateTime                                     
$startofmonth = Get-Date $lastmonth -day 1 -hour 0 -minute 0 -second 0    
$endofmonth = (($startofmonth).AddMonths(1).AddSeconds(-1))

This returns the following which is correct:

$lastMonth: Sunday, October 5, 2014 10:42:56 AM

$startOfMonth: Wednesday, October 1, 2014 12:00:00 AM

$endOfMonthFriday, October 31, 2014 11:59:59 PM

Now, I want to use these variables in my script to obtain the list of certificates that were issued in the previous month. So, I connect to the certDB, obtain the column index numbers for the columns I want to return, set my restrictions for the query, define my return columns, and iterate over each column based upon the request.resolvedwhen dates of 1st day and last day of the previous month.

I am retuning the certs and columns I request, except that any date returned such as notbefore, notafter, resolvedwhen are +6 hours off compared to the cert manager mmc.

For instance, my script will return a the following data...

CommonName               : commonname.domain.com
RequestID                     : 733
NotBefore                     : 10/31/2014 8:09:22 PM
notafter                        :
Request.ResolvedWhen  : 10/31/2014 8:19:22 PM
Status                           : Issued

however the cert manager shows the actual notbefore, notafter, and resolution dates as -6 hours difference.

(NotBefore) certificate Effective date: 10/31/2014 2:09 PM

(notAfter) Certificate expiration date: 10/30/2016 2:09 PM

(ResolvedWhen) Request Resolution date: 10/31/2014 2:19 PM

I cant figure out why it is changing the returned results for the dates. Assuming it has to do with UTC offset but cant figure out how to fix. This actually affects the list of certs returned because everything is off 6 hours. It could return less that were actually issued if they were done on the last day of the month.

Assistance greatly appreciated.

Brian

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles