You do not need to install a separate PowerShell module on Windows; the built-in Certificate provider exposes certificate stores through the Cert: drive.^1^
Examine certificate stores
Open PowerShell. Use Run as administrator when inspecting or managing Local Computer stores; Current User inspection normally does not require elevation.
# Confirm that the Certificate provider is available
Get-PSProvider -PSProvider Certificate
# Display the two main store scopes
Get-ChildItem Cert:\
# List personal certificates for the signed-in user
Get-ChildItem Cert:\CurrentUser\My
# List personal certificates installed for the computer
Get-ChildItem Cert:\LocalMachine\My
CurrentUser contains stores associated with the signed-in user. LocalMachine contains computer-wide stores. Other common store names include:
-
My — Personal certificates
-
Root — Trusted Root Certification Authorities
-
CA — Intermediate Certification Authorities
The Certificate provider is available only when PowerShell is running on Windows.^2^
Display and verify certificate details
The following read-only inventory lists the most useful properties:
Get-ChildItem Cert:\CurrentUser\My |
Select-Object Subject, Issuer, Thumbprint, NotBefore, NotAfter,
HasPrivateKey, DnsNameList, EnhancedKeyUsageList |
Format-List
To examine one certificate, copy its thumbprint from the preceding output:
$thumbprint = 'REPLACE_WITH_THUMBPRINT'
$cert = Get-Item "Cert:\LocalMachine\My\$thumbprint"
$cert | Format-List Subject, Issuer, SerialNumber, Thumbprint,
NotBefore, NotAfter, HasPrivateKey, DnsNameList,
EnhancedKeyUsageList
Certificates are represented as X509Certificate2 objects and are addressed by thumbprint in the Cert: drive.^1^
To find certificates that have already expired or will expire within 30 days:
$today = Get-Date
$limit = $today.AddDays(30)
Get-ChildItem Cert:\CurrentUser\My, Cert:\LocalMachine\My |
Where-Object { $_.NotAfter -le $limit } |
Select-Object Subject, Thumbprint, NotAfter,
@{Name='Expired'; Expression={$_.NotAfter -lt $today}}
Validate an SSL server certificate
On systems where Test-Certificate is available, specify the expected DNS name:
Get-ChildItem Cert:\LocalMachine\My |
Test-Certificate -Policy SSL -DNSName 'dns=server.contoso.com'
Test-Certificate checks the certificate against the supplied SSL policy and checks revocation by default. A result of True means it passed that policy in the selected chain context; it does not replace an end-to-end test of the application using the certificate.^3^
Graphical inspection
For a visual check of the certification chain:
- Run
certmgr.msc for the Current User stores.
- Run
certlm.msc for the Local Computer stores.
- Open the certificate and inspect:
- General for validity status
- Details for subject, issuer, thumbprint, DNS names, and intended purposes
- Certification Path for root and intermediate-chain trust
Avoid adding or deleting certificates—particularly under Cert:\LocalMachine\Root—unless the issuer and required destination are known. Changing the computer’s Trusted Root store changes which certificate authorities the whole computer trusts.^3^
References
- about_Certificate_Provider
- about_Providers
- Inspect certificates and manage certificate store contents