How to Get date of ssl certificate with power shell

Adrião Ferreira Ramos 0 Reputation points
2024-02-28T13:25:30.42+00:00

I have a list of servers running IIS with a SSL certificate. it is about to expire. Is there a script or a command I can run and get the SSL certificate date of expiration in all servers and send it to a file?

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,507 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ian Xue (Shanghai Wicresoft Co., Ltd.) 36,256 Reputation points Microsoft Vendor
    2024-02-29T05:37:38.98+00:00

    Hi Adrião Ferreira Ramos,

    The X.509 certificate stores and certificates can be accessed on the Cert drive like below.

    Get-ChildItem -Path Cert:\LocalMachine\My | Select-Object Subject, NotAfter | Export-Csv -Path C:\Temp\certs.csv 
    

    This will export the certificates in the Personal store to a CSV file.

    Best Regards,

    Ian Xue


    If the Answer is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.