A positional parameter cannot be found that accepts argument '[System.Convert]::ToBase64String'

Patel, Amit 20 Reputation points

While I am running the below command, I am getting error "Get-Content: A positional parameter cannot be found that accepts argument '[System.Convert]::ToBase64String'."

What could be the issue?

# [Powershell]
# Get content of certificate as byte stream, and convert to base64 string and store in .txt
$fileContentBytes = get-content ‘certificate.pfx' -AsByteStream [System.Convert]::ToBase64String($fileContentBytes) | Out-File ‘pfx-encoded-bytes.txt’
Azure Key Vault
Azure Key Vault
An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.
960 questions
Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
1,647 questions
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
1,532 questions
0 comments No comments
{count} votes

Accepted answer
  1. Rich Matheisen 42,826 Reputation points

    Put the expression "[System.Convert]::ToBase64String($fileContentBytes)" within parentheses. I.e.

    ( [System.Convert]::ToBase64String($fileContentBytes) )

0 additional answers

Sort by: Most helpful