Reputation: 13
I'm trying to store the thumbprint in a variable by executing
$thumbprint = (Get-ChildItem -path cert:\localmachine\my | where {$_.Subject -like "*.contoso.com."}).Thumbprint
I seem to capture two thumbprints one for the ssl wildcard certificate and the client/server authentication certificate.
I only want to capture the ssl wildcard certificate
$thumbprint = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
What am I missing here?
Upvotes: 1
Views: 647
Reputation: 1323
The *
character in your filter is a wildcard that is matching more than just the asterisk character. Try modifying your filter to use -eq
. Perhaps something like the following:
... | where { $_.Subject -eq "CN=*.contoso.com." }
Or, if this is within a script you can escape the *
with a single backtick. If run from the command line, escape it with a double backtick. As per the documentation for Supporting Wildcard Characters in Cmdlet Parameters.
... | where { $_.Subject -like "``*.contoso.com." }
Upvotes: 2