Skip to content

Instantly share code, notes, and snippets.

@techdecline
Created September 17, 2020 08:09
Show Gist options
  • Select an option

  • Save techdecline/684f13d6fcbad81c2b4abc7b0e83d88f to your computer and use it in GitHub Desktop.

Select an option

Save techdecline/684f13d6fcbad81c2b4abc7b0e83d88f to your computer and use it in GitHub Desktop.
function Get-ThumbprintFromCertFile {
param (
[Parameter(Mandatory)]
[ValidateScript({Test-Path $_})]
[ValidatePattern(".*\.cer")]
[String]$CertificatePath
)
$CertificatePath = (Get-Item $CertificatePath).FullName
try {
$certObj = New-Object -TypeName System.Security.Cryptography.X509Certificates.X509Certificate2 `
-ArgumentList "$CertificatePath"
}
catch {
throw "Could not load Certificate"
}
return $certObj.Thumbprint
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment