Mark Minasi's Tech Forum
Register Calendar Latest Topics Chat

  Author   Comment  

Avatar / Picture

Associate Troublemaker Apprentice
Posts: 741
Reply with quote  #1 
So in the last while I'be been dealing with a lot of issues with certs.
So rather than get the MMc etc I have this:
Its clunky, but works.
But is there a better way?
I'm looking to get my titles into the text file so I can drop the output into a server or site document.


mkdir c:\CertOutput
Set-Location Cert:\LocalMachine\my
echo "List of Certificates" | Out-File c:\CertOutput\CertOutput.txt
ls | Out-File c:\CertOutput\CertOutput.txt -append
Get-ChildItem -path cert:\LocalMachine\My | Format-Table Thumbprint, subject, FriendlyName | Out-File c:\CertOutput\CertOutput.txt -width 250 -append
echo "List of Certificates Expiring in 365 Days" | Out-File c:\CertOutput\CertOutput.txt -append
GET-CHILDITEM –RECURSE –EXPIRINGINDAYS 365 | Out-File c:\CertOutput\CertOutput.txt -append
echo "List of Certificates Expiring in 90 Days" | Out-File c:\CertOutput\CertOutput.txt -append
GET-CHILDITEM –RECURSE –EXPIRINGINDAYS 90 | Out-File c:\CertOutput\CertOutput.txt -append
echo "List of Certificates Expiring in 30 Days" | Out-File c:\CertOutput\CertOutput.txt -append
GET-CHILDITEM –RECURSE –EXPIRINGINDAYS 30 | Out-File c:\CertOutput\CertOutput.txt -append
# Getting other information for explicit certificates
# Cert 1
# The guid is a hardcoded guid from the cert list!! Not a common cert name!!
$cert = Get-ChildItem cert:\localmachine\my\E5F0EF5845AECA4E35C480417ECBC0F99333076D
$cert | Format-List -Property *
echo "Cert 1 - SAN Names" | Out-File c:\CertOutput\CertOutput.txt -append
($cert.Extensions | Where-Object {$_.Oid.FriendlyName -eq "subject alternative name"}).Format(1) | Out-File c:\CertOutput\CertOutput.txt -append
echo "Cert 1 - CRL Dist List" | Out-File c:\CertOutput\CertOutput.txt -append
($cert.Extensions | Where-Object {$_.Oid.FriendlyName -eq "CRL Distribution Points"}).Format(1) | Out-File c:\CertOutput\CertOutput.txt -append
echo "Cert 1 - CA Authourity List" | Out-File c:\CertOutput\CertOutput.txt -append
($cert.Extensions | Where-Object {$_.Oid.FriendlyName -eq "Authority Information Access"}).Format(1) | Out-File c:\CertOutput\CertOutput.txt -append

Have you tried turning it off and walking away? The next person can fix it!

New to the forum? Read this

Avatar / Picture

Senior Member
Posts: 165
Reply with quote  #2 
It works Joseph, so it's good.

A better way is to make it a function and have the output as an object so you can do more things with it if you want

Have SpaceSuit, Will Travel


Avatar / Picture

New Friend (or an Old Friend who Built a New Account)
Posts: 45
Reply with quote  #3 
Thanks for the comment.
By the way I didn't write the code that turns my query into legible English for the cert info, that is borrowed! I'll get to understand it , in another 2 years.

Thanks to Auto-correct on my mad tablet it remove my question.

The queries against the cert seem to be individual. How can I drop the info into one function as you say?

Press any key....
Yes, any key....
OK, try the space bar.
Previous Topic | Next Topic

Quick Navigation: