Convert pfx certificate to base64 string using Powershell

To get Certificate data from PFX File Run below Script in powershell.

 

$Certfile = "Enter your UNC Path"
[System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes($Certfile))

To Export it to a text file

$Certfile = "Enter your UNC Path for Certificate in .PFX(Include Extension)"
$OutText = "Enter Output text file "
[System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes($Certfile))  | out-File $OutText