How to find certificates that are expiring on your server using PowerShell– Part 1

Home > Blogs > PowerShell > How to find certificates that are expiring on your server using PowerShell– Part 1

How to find certificates that are expiring on your server using PowerShell– Part 1

Like This Blog 2 Jason Helmick
Added by January 14, 2013

So, I’m often asked how to quickly find certificates that are about to expire so that they can be replaced. Here is a quick way to list the days remaining before the certificates on your server are about to expire.

PS> Get-ChildItem -Path Cert:\LocalMachine\My | Select-Object -Property PSComputerName, Subject, @{n=’ExpireInDays’;e={($_.notafter – (Get-Date)).Days}}

By adding a Where-Object filter, you can filter the list so that only certificates that are going to expire in 90 days are displayed.

PS> Get-ChildItem -Path Cert:\LocalMachine\My | Select-Object -Property PSComputerName, Subject, @{n=’ExpireInDays’;e={($_.notafter – (Get-Date)).Days}} | Where-Object {$_.ExpireInDays -lt 90}

If you have multiple servers such as a web farm, you can use PowerShell Remoting to check all your servers at once! Check out the same one-liners using PowerShell remoting Locating IIS certificates before the expire.

Pretty cool huh?

For more, read Part 2: How to find certificates that are expiring on your server using PowerShell

Knowledge is PowerShell

Jason Helmick
Director of PowerShell Technologies
Interface Technical Training

Videos You May Like

How to Build in a PSMethod to your PowerShell Code

0 65 0

In this video, PowerShell instructor Jason Yoder shows how to add Methods (PSMethod) to your code using free software that’s added into the PSObject. For instructor-led PowerShell courses, see our course schedule. Microsoft Windows PowerShell Training Download the Building Methods PowerShell script</a> used in this video. <# ╔══════════════════════════════════════════════════════════════════════════════╗ ║ ║ ║ Building Methods ║ ╟──────────────────────────────────────────────────────────────────────────────╢ … Continue reading How to Build in a PSMethod to your PowerShell Code

How to use the PowerShell Script Analyzer to Clean Up Your Code

0 1211 2

In this video, PowerShell instructor Jason Yoder demonstrates how you can use the PowerShell Script Analyzer to help you format your code to best-practices. For instructor-led PowerShell training classes, see our course schedule: Microsoft Windows PowerShell Training Download the PowerShell Analyzer scripts used in this video. <# ╔══════════════════════════════════════════════════════════════════════════════╗ ║ ║ ║ PowerShell Script Analyzer ║ … Continue reading How to use the PowerShell Script Analyzer to Clean Up Your Code

Configuring Windows Mobility Center and How to Turn it On and Off

1 1402 1

Video transcription Steve Fullmer: In our Windows training courses, we often share information about the Windows 8.1 Mobility Center. Mobility Center was introduced for mobile and laptop devices in Windows 7. It’s present and somewhat enhanced in Windows 8. Since we don’t have mobile devices in our classrooms, I decided to take a little bit … Continue reading Configuring Windows Mobility Center and How to Turn it On and Off

Write a Comment

See what people are saying...

    Share your thoughts...

    Please fill out the comment form below to post a reply.