Skip to content

Find Certificate

dscbot edited this page Feb 13, 2024 · 2 revisions

Find-Certificate

SYNOPSIS

Locates one or more certificates using the passed certificate selector parameters.

SYNTAX

Find-Certificate [[-Thumbprint] <String>] [[-FriendlyName] <String>] [[-Subject] <String>]
 [[-DNSName] <String[]>] [[-Issuer] <String>] [[-KeyUsage] <String[]>] [[-EnhancedKeyUsage] <String[]>]
 [[-Store] <String>] [[-AllowExpired] <Boolean>] [<CommonParameters>]

DESCRIPTION

A common function to find certificates based on multiple search filters, including, but not limited to: Thumbprint, Friendly Name, DNS Names, Key Usage, Issuers, etc.

Locates one or more certificates using the passed certificate selector parameters. If more than one certificate is found matching the selector criteria, they will be returned in order of descending expiration date.

EXAMPLES

EXAMPLE 1

Find-Certificate -Thumbprint '1111111111111111111111111111111111111111'

Return certificate that matches thumbprint.

EXAMPLE 2

Find-Certificate -KeyUsage 'DataEncipherment', 'DigitalSignature'

Return certificate(s) that have specific key usage.

EXAMPLE 3

Find-Certificate -DNSName 'www.fabrikam.com', 'www.contoso.com'

Return certificate(s) filtered on specific DNS Names.

EXAMPLE 4

Find-Certificate -Subject 'CN=contoso, DC=com'

Return certificate(s) with specific subject.

EXAMPLE 5

Find-Certificate -Issuer 'CN=contoso-ca, DC=com' -AllowExpired $true

Return all certificates from specific issuer, including expired certificates.

EXAMPLE 6

Find-Certificate -EnhancedKeyUsage @('Client authentication','Server Authentication') -AllowExpired $true

Return all certificates that can be used for server or client authentication, including expired certificates.

EXAMPLE 7

Find-Certificate -FriendlyName 'My IIS Site SSL Cert'

Return certificate based on FriendlyName.

PARAMETERS

-AllowExpired

Allows expired certificates to be returned.

Type: Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: 9
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-DNSName

The subject alternative name of the certificate to export must contain these values.

Type: String[]
Parameter Sets: (All)
Aliases:

Required: False
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-EnhancedKeyUsage

The enhanced key usage of the certificate to find must contain these values.

Type: String[]
Parameter Sets: (All)
Aliases:

Required: False
Position: 7
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-FriendlyName

The friendly name of the certificate to find.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Issuer

The issuer of the certificate to find.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 5
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-KeyUsage

The key usage of the certificate to find must contain these values.

Type: String[]
Parameter Sets: (All)
Aliases:

Required: False
Position: 6
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Store

The Windows Certificate Store Name to search for the certificate in. Defaults to 'My'.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 8
Default value: My
Accept pipeline input: False
Accept wildcard characters: False

-Subject

The subject of the certificate to find.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Thumbprint

The thumbprint of the certificate to find.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

System.Security.Cryptography.X509Certificates.X509Certificate2

NOTES

RELATED LINKS

Clone this wiki locally