Gets content that has been encrypted by using the Cryptographic Message Syntax format.
Get-CmsMessage [-Content*] <String> [<CommonParameters>]
Get-CmsMessage [-LiteralPath*] <String> [<CommonParameters>]
Get-CmsMessage [-Path*] <String> [<CommonParameters>]

The Get-CmsMessage cmdlet gets content that has been encrypted using the Cryptographic Message Syntax (CMS) format.

The CMS cmdlets support encryption and decryption of content using the IETF format for cryptographically protecting messages, as documented by RFC5652.

The CMS encryption standard uses public key cryptography, where the keys used to encrypt content (the public key) and the keys used to decrypt content (the private key) are separate. Your public key can be shared widely, and is not sensitive data. If any content is encrypted with this public key, only your private key can decrypt it. For more information about public-key cryptography, see

Get-CmsMessage gets content that has been encrypted in CMS format. It does not decrypt or unprotect content. You can run this cmdlet to get content that you have encrypted by running the Protect-CmsMessage cmdlet. You can specify content that you want to decrypt as a string, or by path to the encrypted content. You can pipe the results of Get-CmsMessage to Unprotect-CmsMessage to decrypt the content, provided that you have information about the document encryption certificate that was used to encrypt the content.

-Content <String>

  • This value is required
  • Accepts pipeline input ByValue

Specifies an encrypted string, or a variable containing an encrypted string.

-LiteralPath <String>

  • This value is required

Specifies the path to encrypted content that you want to get. Unlike Path, the value of LiteralPath is used exactly as it is typed. No characters are interpreted as wildcard characters. If the path includes escape characters, enclose each one in single quotation marks. Single quotation marks tell Windows PowerShell not to interpret enclosed characters as escape characters.

-Path <String>

  • This value is required

Specifies the path to encrypted content that you want to decrypt.


This cmdlet supports the common parameters: Verbose, Debug,ErrorAction, ErrorVariable, WarningAction, WarningVariable,OutBuffer, PipelineVariable, and OutVariable.

  1. Get encrypted content:
       PS C:>Get-CmsMessage -Path "C:UsersTestDocumentsPowerShell ISEFuture_Plans.txt"
       -----BEGIN CMS-----
       -----END CMS-----

    This command gets encrypted content located at C:UsersTestDocumentsPowerShellISEFuture_Plans.txt.

  2. Pipe encrypted content to Unprotect-CmsMessage:
    PS C:> $Msg = Get-CmsMessage -Path "C:UsersTestDocumentsPowerShell ISEFuture_Plans.txt"
    $Msg | Unprotect-CmsMessage -To "?"
    Try the new Break All command

    This command pipes the results of the Get-CmsMessage cmdlet from Example 1 to Unprotect-CmsMessage, to decrypt the message and read it in plain text. In this case, the value of the To parameter is the value of the encrypting certificate’s Subject line. The decrypted message, “Try the new Break All command,” is the result.

Related Links