Expired SSL certificates can lead to service disruptions and security vulnerabilities. Staying on top of hundreds or even thousands of certificates is a critical but often difficult job for any IT team. This post provides the solution: a robust and fully-featured PowerShell certificate scanner. This script is created to simplify the process of tracking SSL/TLS expiration dates, giving you the power to scan multiple websites and services, gather critical certificate details, and receive automated reports in a CSV file or via email.

Downloading PowerShell Certificate Scanner Script

If you are in a rush, feel free and get the script from my Github repo over here or get by running the following code to get it from the PowerShell Gallery

Install-Script -Name CertificateScanner

Prerequisites

  • PowerShell 7 or Windows PowerShell
  • Recommend being a local admin on the PC

15 Aug 2025: Version 3.0.0: Thanks for Alessandro Tanino for his great contribution in expanding this script with loads of new features. The script now support several parameter, such as:

  • Networks: CIDR notation networks
  • Port: Primary HTTPS port
  • TimeoutSeconds: Connection timeout in seconds
  • LDAPS scanning
  • DnsServer: Custom DNS server for reverse lookups
  • GetOsType: Detect operating system of certificate hosts

use .\CertificateScanner.ps1 -Examples for more information

What is PowerShell Certificate Scanner

This PowerShell script scans multiple sites and retrieves the SSL certificate information, mainly:

  • URL
  • Subject CN
  • Issuer
  • Issued Date
  • Expire Date
  • Protocol

Key Features and Parameter Usage

The updated script, now at version 3, introduces several powerful new features. The script is designed to support different parameter sets, allowing for flexible usage in various scenarios.

Core Scanning Parameters

  • -SiteToScan <URL>: Scans a single website or IP address. You can specify a custom port by using the format hostname:port.
  • -Networks <CIDR>: Scans a network range using CIDR notation (e.g., “192.168.1.0/24”). Multiple networks can be scanned by separating them with a comma.
  • -LoadFromFile <FilePath>: Imports a list of URLs or IP addresses from a text file for a bulk scan.

Network Scan and Protocol Parameters

  • -Port <Int>: Specifies the primary HTTPS port to scan (default is 443).
  • -AdditionalHTTPSPorts <Array>: Allows you to scan for HTTPS certificates on multiple non-standard ports, in addition to the main -Port.
  • -IncludeLDAPS: Expands the scan to include LDAPS certificates on port 636 along with the specified HTTPS ports.
  • -LDAPSOnly: Restricts the scan to only check for LDAPS certificates on port 636.
  • -ProtocolVersion <String>: Specifies the SSL/TLS version to use for the scan. This is useful for checking certificates on older, legacy systems that don’t support modern protocols like TLS 1.2. Valid options include “Tls12”, “Tls11”, “Tls”, “Ssl3”, or “Default”.

Advanced Information and Discovery

  • -GetOsType: Attempts to detect the operating system of the host.
  • -DnsServer <String>: A newly added parameter that works with -IncludeReverseDNS. It lets you specify a custom DNS server for all reverse lookup queries, which is crucial for internal networks or specific DNS configurations.
    • -IncludeReverseDNS: Performs a reverse DNS lookup for each IP address to find its associated hostname.

Reporting and Filtering

  • -ExpiresInDays <Int>: A powerful filter that displays only the certificates that will expire within the specified number of days. Using 0 will show only certificates that have already expired.
  • -SaveAsTo <String>: Saves the scan results to a CSV file. If the filename is prefixed with a +, the script will append the new results to an existing file, which is perfect for scheduled monitoring tasks.
  • -EmailSendTo, -EmailFrom, -EmailSMTPServer, etc.: These parameters enable email reporting. The script can send a formatted report of the scan results directly to an email address. You can configure the SMTP server, port, and SSL/TLS settings for secure delivery.

PRO Features

Performance optimization for large networks

  • Use –MaxThreads between 10-50 (test optimal value for your network)
  • Append mode (+filename) is perfect for scheduled monitoring
.\CertificateScanner.ps1 -Networks "10.0.0.0/16" -ExpiresInDays 0 -SaveAsTo +expired_certs.csv

Practical Examples for the Post

To make the post easy to follow, you should include a new section with practical examples that demonstrate the new features. You can organize these examples by functionality.

Example 1: Basic Scans

  • Scan a single website
.\CertificateScanner.ps1 -SiteToScan www.powershellcenter.com
  • Scan a specific network range:
.\CertificateScanner.ps1 -Networks "192.168.1.0/24"
  • Scan from a list of servers in a file:
.\CertificateScanner.ps1 -LoadFromFile C:\servers\critical_servers.txt

Example 2: Advanced Network Discovery

  • Scan a network for certificates, perform OS detection, and use a custom DNS server for hostnames:
.\CertificateScanner.ps1 -Networks "10.0.0.0/16" -GetOsType -IncludeReverseDNS -DnsServer 10.0.0.1 -SaveAsTo C:\reports\network_scan.csv

Example 3: Expiration Monitoring & Automation

  • Find all certificates expiring in the next 30 days and append them to a report:
.\CertificateScanner.ps1 -Networks "192.168.1.0/24" -ExpiresInDays 30 -SaveAsTo +C:\reports\expiring_certs.csv
  • Find all already expired certificates and send an email alert:
.\CertificateScanner.ps1 -Networks "10.1.1.0/24" -ExpiresInDays 0 -EmailSendTo admin@yourco.com -EmailFrom noreply@scanner.com -EmailSMTPServer mail.yourco.com -EmailSubject "URGENT: Expired Certificates Found"

Example 4: LDAPS Scanning

  • Scan a network for both HTTPS and LDAPS certificates:
.\CertificateScanner.ps1 -Networks "192.168.1.0/24" -IncludeLDAPS
  • Scan only for LDAPS certificates and save to a file:
.\CertificateScanner.ps1 -Networks "10.2.0.0/24" -LDAPSOnly -SaveAsTo ldaps_certs.csv
  • LDAPS expiration monitoring
.\CertificateScanner.ps1 -Networks "10.0.0.0/16" -LDAPSOnly -ExpiresInDays 60 -SaveAsTo ldaps_expiring.csv
  • High-speed enterprise scan
.\CertificateScanner.ps1 -Networks "10.0.0.0/8" -MaxThreads 50 -TimeoutSeconds 2 -Port 443 -AdditionalHTTPSPorts 8443,9443
5/5 - (1 vote)