1. Aaron Jensen
  2. Carbon
  3. Issues
Issue #130 resolved

Get-Certificate doesn't find any certificates in [System.Security.Cryptography.X509Certificates.StoreName]::CertificateAuthority

Alexander Groß
created an issue

Get-Certificate uses the System.Security.Cryptography.X509Certificates.StoreName value to construct the PowerShell path below cert:\.

For [System.Security.Cryptography.X509Certificates.StoreName]::CertificateAuthority this leads to e.g. cert:\LocalMachine\CertificateAuthority but the actual path is cert:\LocalMachine\CA (CA is the certificate store's name as constructed by $(Get-CertificateStore -StoreLocation LocalMachine -StoreName CertificateAuthority).Name)

Comments (5)

  1. Aaron Jensen repo owner

    What .Name property? On which object?

    If Microsoft adds a new StoreName value (not likely) and the PowerShell teams muffs the name again, I guess I'll convert the if statement to a lookup table. :(

  2. Alexander Groß reporter

    Since the $StoreName parameter is a Security.Cryptography.X509Certificates.StoreName you could to the following:

    $(Get-CertificateStore -StoreLocation $StoreLocation -StoreName $StoreName).Name
    

    Here's the snippet from a PS script:

    PS C:\Windows\system32> $storeName = [System.Security.Cryptography.X509Certificates.StoreName]::CertificateAuthority
    PS C:\Windows\system32> $store = Get-CertificateStore -StoreLocation LocalMachine -StoreName $storeName
    PS C:\Windows\system32> $store.Name
    CA
    
  3. Log in to comment