I'm having trouble with this. I have a text file (generated with the certutil) I want to be able to go through the file and send users an email when their certificates are going to expire. Here's a sample of the file
I can read the text file into an array ok, but how would I pull the results from the fields and just put the results in variables. For example Certificate Expiration Data: I just want to put the date into a variable, and do the same for all the others.
Issued Request ID: 0x220 (544)
Certificate Expiration Date: 10/9/2008 12:04 PM
User Principal Name: "user2@company.com"
Certificate Template: "User"
Here's what i have, it's not much
Code:
11/6/2008 12:00 AM
10/7/2008 8:00 AM
Schema:
Column Name Localized Name Type MaxLength
---------------------------- ---------------------------- ------ ---------
RequestID Issued Request ID Long 4 -- Indexed
NotAfter Certificate Expiration Date Date 8 -- Indexed
UPN User Principal Name String 2048 -- Indexed
CertificateTemplate Certificate Template String 254 -- Indexed
Row 1:
Issued Request ID: 0x21f (543)
Certificate Expiration Date: 10/8/2008 11:03 AM
User Principal Name: "_lossing@rand.org"
Certificate Template: "1.3.6.1.4.1.311.21.8.1452867.10910400.12403072.16600237.1244368.171.16744963.12748033" company Smartcard Logon
Row 2:
Issued Request ID: 0x332 (818)
Certificate Expiration Date: 10/8/2008 4:20 PM
User Principal Name: EMPTY
Certificate Template: "CAExchange"
Row 3:
Issued Request ID: 0x220 (544)
Certificate Expiration Date: 10/9/2008 12:04 PM
User Principal Name: "user2@company.com"
Certificate Template: "User"
I can read the text file into an array ok, but how would I pull the results from the fields and just put the results in variables. For example Certificate Expiration Data: I just want to put the date into a variable, and do the same for all the others.
Issued Request ID: 0x220 (544)
Certificate Expiration Date: 10/9/2008 12:04 PM
User Principal Name: "user2@company.com"
Certificate Template: "User"
Here's what i have, it's not much
Code:
Dim objShell, objNetwork, objFSO
Set objShell = CreateObject("WScript.Shell")
Set objNetwork = WScript.CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FilesystemObject")
'==========================================================================
' STATIC VARIABLE ASSIGNMENTS
'==========================================================================
Const FOR_READING = 1, FOR_WRITING = 2, FOR_APPENDING = 8
'==========================================================================
' MAIN SCRIPT CODE
'==========================================================================
Set strCert = objFSO.OpenTextFile("C:\expiring_certificates.txt",1)
strArray = Split(strCert.ReadAll,vbCrLf)
For Each cert In strArray
WScript.Echo cert
Next