Skip to content

Instantly share code, notes, and snippets.

@marrobi
Created February 14, 2017 13:24
Show Gist options
  • Save marrobi/12587f8ef038a53103fd976c83651054 to your computer and use it in GitHub Desktop.
Save marrobi/12587f8ef038a53103fd976c83651054 to your computer and use it in GitHub Desktop.
Encode PFX as Base64
# path to file
$fileName = "C:\tmp\mycert.pfx"
# get content of the file as Byte
$fileContentBytes = get-content $fileName -Encoding Byte
# convert to Base64
$fileContentEncoded = [System.Convert]::ToBase64String($fileContentBytes)
# convert to secure string
$secret = ConvertTo-SecureString -String $filecontentencoded -AsPlainText -Force
# store the secret in KeyVault
Set-AzureKeyVaultSecret -VaultName $vaultName -Name $certificateName -SecretValue $secret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment