-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathWrite-DPEncryptedContent.ps1
More file actions
38 lines (31 loc) · 944 Bytes
/
Write-DPEncryptedContent.ps1
File metadata and controls
38 lines (31 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<#
.SYNOPSIS
Writes the string as an XML file in the user area with the
given filename.
.DESCRIPTION
This PowerShell routine will save the string in its
encrypted form as a system.secure.string an XML file
.EXAMPLE
Write-DPEncryptedContent 'Fee-fi-fo-fum,
I smell the blood of an Englishman,
Be he alive, or be he dead
I''ll grind his bones to make my bread' "$env:USERPROFILE\SecretKey"
.PARAMETER String
the string that you wish to encrypt.
.PARAMETER Filename
The file you want to save the encrypted text in
#>
function Write-DPEncryptedContent
{
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true,
HelpMessage = 'the string that you wish to encrypt.')]
[String]$String,
[Parameter(Mandatory = $true,
HelpMessage = 'The file you want to save the encrypted text in')]
[String]$Filename
)
$String | ConvertTo-SecureString -AsPlainText -Force | Export-Clixml $Filename -Force
}