Unprotect-String

Decrypts a string using the Data Protection API (DPAPI).

Syntax

Unprotect-String [-ProtectedString] <String> [<CommonParameters>]

Description

Decrypts a string with the Data Protection API (DPAPI). The string must have also been encrypted with the DPAPI and the same scope used to decrypt as was used to encrypt.

Related Commands

Parameters

Name Type Description Required? Pipeline Input Default Value
ProtectedString String The text to encrypt. true true (ByValue)

EXAMPLE 1

$encryptedPassword = Protect-String -String 'MySuperSecretPassword' -ForUser

PS> $password = Unprotect-String -ProtectedString $encryptedPassword

Decrypts a protected string which was encrypted at the current user or default scopes.

EXAMPLE 2

$encryptedPassword = Protect-String -String 'MySuperSecretPassword' -ForComputer

PS> $cipherText = Unprotect-String -ProtectedString $encryptedPassword

Encrypts the given string and stores the value in $cipherText. Because the string was encrypted at the LocalMachine scope, the string must be decrypted at the same scope.

EXAMPLE 3

Protect-String -String 'NotSoSecretSecret' -ForUser | Unprotect-String

Demonstrates how Unprotect-String takes input from the pipeline. Adds 'NotSoSecretSecret' to the pipeline.