Skip to content

Instantly share code, notes, and snippets.

@MasayukiOzawa
MasayukiOzawa / Convert-PfxToPem.ps1
Created December 3, 2024 10:48 — forked from rmbolger/Convert-PfxToPem.ps1
Convert-PfxToPem.ps1
# Adapted from Vadims Podāns' amazing work here.
# https://www.sysadmins.lv/blog-en/how-to-convert-pkcs12pfx-to-pem-format.aspx
#
# Also, if you need a more complete PKI PowerShell module, he has authored one here:
# https://github.com/Crypt32/PSPKI
#
# This version of the function includes a few fixes from the module's version of the
# function and changes up the output options so you get separate .crt/.key files by
# default named the same as the pfx file (or thumbprint if directly referencing a cert).
# -IncludeChain adds an additional -chain.pem. Relative paths are now