Deepthi Gosula
asked on
Powershell console output Parsing
Hi Experts ,
I have a requirement to parse the PowerShell console output of a command which look like below :
========================== ========== ========== ========== ========== =====
Certificates in database D:\IBM\MQSeries\data\SSL\K ey.kdb:
ibmwebspheremqmqhub
From: Thursday, August 13, 2015 4:29:12 PM EDT To: Saturday, December 28, 2016 4:29:12 PM EDT
"Infrastructure Authority"
From: Thursday, March 1, 2012 1:02:04 PM EST To: Wednesday, March 1, 2014 1:12:04 PM EST
"VeriSign Server CA"
From: Tuesday, January 18, 2005 7:00:00 PM EST To: Sunday, January 18, 2015 6:59:59 PM EST
5724-H72 (C) Copyright IBM Corp. 1994, 2011. ALL RIGHTS RESERVED.
========================== ========== ========== ========== ========== =====
In the above text below are the certificates
1) ibmwebspheremqmqhub
2) "Infrastructure Authority"
3) "VeriSign Server CA"
Below each certificate its valid from date and to date is mentioned.
I wanted to extract the date of expiry of each certificate in to a variable and if the expiry date is below 30 days notify that particular certificate is due to expire or if it is less than 0 days it has already expired.
I am not sure how to get this done in PowerShell. Please help me on this.
I have a requirement to parse the PowerShell console output of a command which look like below :
==========================
Certificates in database D:\IBM\MQSeries\data\SSL\K
ibmwebspheremqmqhub
From: Thursday, August 13, 2015 4:29:12 PM EDT To: Saturday, December 28, 2016 4:29:12 PM EDT
"Infrastructure Authority"
From: Thursday, March 1, 2012 1:02:04 PM EST To: Wednesday, March 1, 2014 1:12:04 PM EST
"VeriSign Server CA"
From: Tuesday, January 18, 2005 7:00:00 PM EST To: Sunday, January 18, 2015 6:59:59 PM EST
5724-H72 (C) Copyright IBM Corp. 1994, 2011. ALL RIGHTS RESERVED.
==========================
In the above text below are the certificates
1) ibmwebspheremqmqhub
2) "Infrastructure Authority"
3) "VeriSign Server CA"
Below each certificate its valid from date and to date is mentioned.
I wanted to extract the date of expiry of each certificate in to a variable and if the expiry date is below 30 days notify that particular certificate is due to expire or if it is less than 0 days it has already expired.
I am not sure how to get this done in PowerShell. Please help me on this.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sure. Thank you. I will test it out and post it here.
ASKER
The expert is very good in understanding the requirements and gave correct suggestion and solution.
I am glad to get associated with oBdA
I am glad to get associated with oBdA
ASKER
This script works perfect. Thank you very much.
I am new in using regular expressions. I tried to understand the code, but simply lost between lines 3 to 14. Can you please explain me about these lines. this will be very helpful for me to work on similar requirements by self.
Also 2 more things,
1) I wanted to achieve. How to get the details of only one certificate instead of all. example : I want to know about only IBM certificate.
2) How can I run this remotely on multiple machines.
Please help me on this.