web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to retrieve proper...
Power Automate
Answered

How to retrieve properties from a certificate file?

(0) ShareShare
ReportReport
Posted on by 7

Hi All,

 

Good day! I'm working on an initiative where part of the requirements is to get the properties (such as Issuer, NotAfter, Thumbprint, etc) of a certificate file. I tried the following methods but I wasn't able to achieve what I need. Appreciate your inputs in case you have worked with the same requirement before or have an idea how to implement it.

 

Best regards,

Jay

 

iamjaredm_0-1690555266160.png

 

Method 01 : Run VBScript

Script

' Create an instance of the X509Certificate2 class
Set cert = CreateObject("X509Certificate2")

' Load the certificate from a file or other source
cert.Import("<Folder Path>\SampleCert_1.cer")

' Check if the certificate is valid
If cert.IsValid Then
    ' Retrieve the certificate properties
    CommonName = cert.SubjectName.Name
    Issuer = cert.IssuerName.Name
    SerialNumber = cert.SerialNumber
    Thumbprint = cert.Thumbprint
    ValidFrom = cert.NotBefore
    ValidTo = cert.NotAfter
    
    ' Display the certificate properties
    WScript.Echo "Common Name: " & CommonName
    WScript.Echo "Issuer: " & Issuer
    WScript.Echo "Serial Number: " & SerialNumber
    WScript.Echo "Thumbprint: " & Thumbprint
    WScript.Echo "Valid From: " & ValidFrom
    WScript.Echo "Valid To: " & ValidTo
Else
    ' Certificate is not valid
    WScript.Echo "Invalid certificate"
End If

' Clean up
Set cert = Nothing

 

Result

Script returned an error <Folder Path>\AppData\Local\Temp\Robin\wt1xx2uaddz.tmp(6, 1) Microsoft VBScript runtime error: ActiveX component can't create object: 'X509Certificate2'

 

Method 02 : Run PowerShell Script

 

Script

$CertificatePath = "<Folder Path>\SampleCert_1.cer"

try {
# Load the certificate from the specified path
$certificate = Get-ChildItem -Path $CertificatePath | Select-Object -First 1

# Check if the certificate is valid
if ($certificate -eq $null) {
throw "Certificate not found at the specified path."
}

# Retrieve the certificate properties
$properties = @{
Subject = $certificate.Subject
Issuer = $certificate.Issuer
NotBefore = $certificate.NotBefore
NotAfter = $certificate.NotAfter
Thumbprint = $certificate.Thumbprint
}

# Output the certificate properties
Write-Output $properties
}
catch {
# Log and handle any errors
Write-Error $_.Exception.Message
}

 

Result

Script returned below output but values are empty though available when directly checked from certificate details.

 

Name Value
---- -----
Subject
Issuer
NotBefore
Thumbprint
NotAfter

I have the same question (0)
  • Verified answer
    Nived_Nambiar Profile Picture
    18,136 Super User 2026 Season 1 on at

    Hi @iamjaredm 

     

    Could you try this powershell script ?

     

     

     

    # Replace 'C:\Path\To\Your\Certificate.pfx' with the actual path to your PFX certificate file
    $certPath = 'C:\Path\To\Your\Certificate.pfx'
    
    # Replace 'YourCertificatePassword' with the actual password protecting your PFX certificate (if applicable)
    $certPassword = ConvertTo-SecureString -String 'YourCertificatePassword' -Force -AsPlainText
    
    # Load the certificate from the PFX file
    $certificate = Get-PfxCertificate -FilePath $certPath -Password $certPassword
    
    # Displaying basic certificate properties
    Write-Host "Certificate Subject: $($certificate.Subject)"
    Write-Host "Certificate Issuer: $($certificate.Issuer)"
    Write-Host "Thumbprint: $($certificate.Thumbprint)"
    Write-Host "Serial Number: $($certificate.SerialNumber)"
    Write-Host "Expiration Date: $($certificate.NotAfter)"
    Write-Host "Friendly Name: $($certificate.FriendlyName)"
    
    # Additional properties can be retrieved as needed based on your requirements.
    # For example, if you want to access the certificate's public key, you can use:
    # $publicKey = $certificate.PublicKey.Key
    # Write-Host "Public Key Algorithm: $($publicKey.KeyAlgorithm)"
    # Write-Host "Public Key Size: $($publicKey.KeySize)"
    
    # Remember to handle any exceptions that might occur during certificate loading.
    
    

     

     

    Let me know whether it worked for you 🙂

     

  • iamjaredm Profile Picture
    7 on at

    Thank you so much, @Nived_Nambiar! It worked for me 😊

  • iamjaredm Profile Picture
    7 on at

    Thank you so much, @Nived_Nambiar! It worked for me😊

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 594

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 281 Super User 2026 Season 1

Last 30 days Overall leaderboard