PowerShell Genie

Check certificate files in a folder

Script 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Get-ChildItem recurses through $Path with a -Filter of *.cer and reports each match with its full path, last write time, and size.

The script

1PS> $Path = "C:\Sample"
2PS> Get-ChildItem $Path -Filter *.cer -Recurse | Select-Object FullName,LastWriteTime,Length

Script reader

Inspect before you run

Inspection only

Inspect the script below. It does not run in this browser.

Inspection only — no command has run.

    Show reference output
    1 FullName LastWriteTime Length
    2 -------- ------------- ------
    3 C:\Sample\server.cer 9/10/2026 10:00:00 AM 18432
    Inspect this example’s structure

    Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.

    $Path = "C:\Sample" Get-ChildItem $Path -Filter *.cer -Recurse | Select-Object FullName,LastWriteTime,Length
    1. Stage 1$PathPositional values or no named parameters
    2. Stage 2Select-ObjectPositional values or no named parameters

      How it works

      Get-ChildItem recurses through $Path with a -Filter of *.cer and reports each match with its full path, last write time, and size.

      Adapting it

      The -Filter parameter accepts a single pattern, so switch to -Include with an array covering pfx, pem, and crt, and remember that -Include needs -Recurse or a trailing wildcard on the path before it does anything.

      If the result is unexpected

      Certificate files in a folder cannot be read consistently.

      File formats, private-key protection and passwords differ between exported certificate containers.

      1. Identify each file format and inspect its public certificate metadata using the appropriate reader.

      Validate the result

      Readable files report expected subject, thumbprint and expiry; protected or invalid files are reported separately.

      Keep the check reliable

      Do not log certificate passwords or export private keys merely to complete an inventory.

      Primary documentation

      Get-ChildItem reference

      Continue
      Genie guideCheck certificate files in a folder

      Get-ChildItem recurses through $Path with a -Filter of *.cer and reports each match with its full path, last write time, and size.