Unprotect-CmsMessage
Decrypts content that has been encrypted by using the Cryptographic Message Syntax format.
구문
ByWinEvent (기본값)
Unprotect-CmsMessage
[-EventLogRecord] <EventLogRecord>
[[-To] <CmsMessageRecipient[]>]
[-IncludeContext]
[<CommonParameters>]
ByContent
Unprotect-CmsMessage
[-Content] <string>
[[-To] <CmsMessageRecipient[]>]
[-IncludeContext]
[<CommonParameters>]
ByPath
Unprotect-CmsMessage
[-Path] <string>
[[-To] <CmsMessageRecipient[]>]
[-IncludeContext]
[<CommonParameters>]
ByLiteralPath
Unprotect-CmsMessage
[-LiteralPath] <string>
[[-To] <CmsMessageRecipient[]>]
[-IncludeContext]
[<CommonParameters>]
Description
The Unprotect-CmsMessage
cmdlet decrypts content that has been encrypted using the Cryptographic
Message Syntax (CMS) format.
The CMS cmdlets support encryption and decryption of content using the IETF standard 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 isn't sensitive data. If any content is encrypted with this public key, only your private key can decrypt it. For more information, see Public-key cryptography.
Unprotect-CmsMessage
decrypts content that has been encrypted in CMS format. You can run this
cmdlet to decrypt content that you have encrypted by running the Protect-CmsMessage
cmdlet. You
can specify content that you want to decrypt as a string, by the encryption event log record ID
number, or by path to the encrypted content. The Unprotect-CmsMessage
cmdlet returns the decrypted
content.
Support for Linux and macOS was added in PowerShell 7.1.
예제
Example 1: Decrypt a message
In the following example, you decrypt content that's located at the literal path
C:\Users\Test\Documents\PowerShell
. For the value of the required To parameter, this example
uses the thumbprint of the certificate that was used to perform the encryption. The decrypted
message, "Try the new Break All command," is the result.
$parameters = @{
LiteralPath = "C:\Users\Test\Documents\PowerShell\Future_Plans.txt"
To = '0f 8j b1 ab e0 ce 35 1d 67 d2 f2 6f a2 d2 00 cl 22 z9 m9 85'
}
Unprotect-CmsMessage -LiteralPath @parameters
Try the new Break All command
Example 2: Decrypt an encrypted event log message
The following example gets an encrypted event from the PowerShell event log and decrypts it using
Unprotect-CmsMessage
.
$event = Get-WinEvent Microsoft-Windows-PowerShell/Operational -MaxEvents 1 |
Where-Object Id -EQ 4104
Unprotect-CmsMessage -EventLogRecord $event
Example 3: Decrypt encrypted event log messages using the pipeline
The following example gets all encrypted events from the PowerShell event log and decrypts them
using Unprotect-CmsMessage
.
Get-WinEvent Microsoft-Windows-PowerShell/Operational |
Where-Object Id -EQ 4104 |
Unprotect-CmsMessage
매개 변수
-Content
Specifies an encrypted string, or a variable containing an encrypted string.
매개 변수 속성
형식: | String |
Default value: | None |
와일드카드 지원: | False |
DontShow: | False |
매개 변수 집합
ByContent
Position: | 0 |
필수: | True |
파이프라인의 값: | True |
속성 이름별 파이프라인의 값: | True |
나머지 인수의 값: | False |
-EventLogRecord
Specifies an event log record that contains a CMS encrypted message.
매개 변수 속성
형식: | PSObject |
Default value: | None |
와일드카드 지원: | False |
DontShow: | False |
매개 변수 집합
ByWinEvent
Position: | 0 |
필수: | True |
파이프라인의 값: | True |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
-IncludeContext
Determines whether to include the decrypted content in its original context, rather than output the decrypted content only.
매개 변수 속성
형식: | SwitchParameter |
Default value: | None |
와일드카드 지원: | False |
DontShow: | False |
매개 변수 집합
(All)
Position: | Named |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
-LiteralPath
Specifies the path to encrypted content that you want to decrypt. Unlike Path, the value of LiteralPath is used exactly as it's typed. No characters are interpreted as wildcard characters. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.
매개 변수 속성
형식: | String |
Default value: | None |
와일드카드 지원: | False |
DontShow: | False |
매개 변수 집합
ByLiteralPath
Position: | 0 |
필수: | True |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
-Path
Specifies the path to encrypted content that you want to decrypt.
매개 변수 속성
형식: | String |
Default value: | None |
와일드카드 지원: | False |
DontShow: | False |
매개 변수 집합
ByPath
Position: | 0 |
필수: | True |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
-To
Specifies one or more CMS message recipients, identified in any of the following formats:
- An actual certificate (as retrieved from the Certificate provider).
- Path to the a file containing the certificate.
- Path to a directory containing the certificate.
- Thumbprint of the certificate (used to look in the certificate store).
- Subject name of the certificate (used to look in the certificate store).
매개 변수 속성
형식: | |
Default value: | None |
와일드카드 지원: | False |
DontShow: | False |
매개 변수 집합
(All)
Position: | 1 |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
입력
EventLogRecord
String
You can pipe an object containing encrypted content to this cmdlet.
출력
String
This cmdlet returns the unencrypted message.