Check certificate files in a folder
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
Script reader
Inspect before you run
Inspect the script below. It does not run in this browser.
Inspection only — no command has run.
Show reference output
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- Stage 1$Path
Positional values or no named parameters - Stage 2Select-Object
Positional 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.
- 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.