From fe6a687e14292052c4c8023ba1eed73979a7346c Mon Sep 17 00:00:00 2001 From: OCram85 Date: Thu, 4 Apr 2019 15:52:01 +0200 Subject: [PATCH] simplify cs cret lookup --- src/Item/New-CredentialStoreItem.ps1 | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Item/New-CredentialStoreItem.ps1 b/src/Item/New-CredentialStoreItem.ps1 index 4119aab..81a3524 100644 --- a/src/Item/New-CredentialStoreItem.ps1 +++ b/src/Item/New-CredentialStoreItem.ps1 @@ -118,16 +118,11 @@ function New-CredentialStoreItem { if ($Credential.UserName) { try { if ($null -eq $CSContent.PfxCertificate) { - $Cert = Get-ChildItem -Recurse -Path 'Cert:' | Where-Object { - $_.Thumbprint -eq $CSContent.Thumbprint - } | Select-Object -First 1 + $Cert = Get-CSCertificate -Thumbprint $CSContent.Thumbprint if ($null -eq $Cert) { - if ($isLinux) { - throw "There is no windows certificate store on linux systems!" - } $ErrorParams = @{ ErrorAction = 'Stop' - Exception = [System.Exception]::new( + Exception = [System.Security.Cryptography.X509Certificates.FileNotFoundException]::new( ('Could not find the linked certificate with thumbprint {0}' -f $CSContent.Thumbprint) ) }