From remote machine how to get details for pfx certificates like certificate name, expiry date, subject, valid from

Himanshuk 161 Reputation points
2020-12-16T16:14:13.703+00:00
icm -cn "Server01" -credentials $mycred `
                 -scriptblock { Get-ChildItem -path cert:\LocalMachine\My }

this gives me certificate list but there are certificates with .pfx extensions those are also installed
how to get the details for those certificates

I have tried

Invoke-Command -ComputerName "Server01" -ScriptBlock {Get-PfxCertificate -FilePath "C:\Text\TestNoPassword.pfx"} -Authentication CredSSP

Invoke-Command -ComputerName "Server01" -ScriptBlock {Get-PfxCertificate -FilePath "C:\Text\TestNoPassword.pfx"} -credentials $mycred

but not getting out put
I expect certificate name, thumbprint, expiry date, like details for pfx certificates same as I got from very first command from the note

Windows Server Security
Windows Server Security
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.Security: The precautions taken to guard against crime, attack, sabotage, espionage, or another threat.
1,782 questions
0 comments No comments
{count} votes

Accepted answer
  1. Himanshuk 161 Reputation points
    2020-12-17T11:33:40.317+00:00

    Using new cmdlet Get-PfxData resolves the issue.( prob with Get-pfxcertificate is unable to pass password in the script)

    $mypwd = ConvertTo-SecureString -String "1234" -Force -AsPlainText  
      
    $mypfx = Get-PfxData -FilePath C:\mypfx.pfx -Password $mypwd| select FriendlyName, notAfter,notefore, thumbprint   
    

    https://learn.microsoft.com/en-us/powershell/module/pkiclient/get-pfxdata?view=win10-ps

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Daisy Zhou 21,361 Reputation points Microsoft Vendor
    2020-12-17T10:24:07.507+00:00

    Hello anonymous user,

    Thank you for posting here.

    Would you please tell us what certificate name is? Do you mean frienlyname or certificate name?

    I did a test in my lab as below:

    1.I have two .pfx certificates (C:\11111.pfx and C:\2222.pfx) on server named DC2019.
    49152-er1.png
    2.On another machien, I get the FriendlyName, NotAfter, NotBefore, Subject,Thumbprint of the two certs on DC2019 using command.
    Invoke-Command -ComputerName DC2019 -ScriptBlock{"C:\11111.pfx", "C:\2222.pfx"|Get-PfxCertificate|select FriendlyName, NotAfter, NotBefore, Subject,Thumbprint}

    Here is the result in my case.

    49171-er2.png

    Tip:
    1.If you mean friendlyname, in my case, there is no frientlyname.
    2.If you mean certificate file name, we can see they are C:\11111.pfx and C:\2222.pfx in my case.

    Hope the information above is helpful. If anything is unclear, please feel free to let us know.

    Best Regards,
    Daisy Zhou

    1 person found this answer helpful.
    0 comments No comments