Created
April 21, 2015 20:09
-
-
Save RaccoonDev/40d2a6e9d47db5449121 to your computer and use it in GitHub Desktop.
Save Password in Encrypted File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Save-Password | |
{ | |
Param | |
( | |
[parameter(Mandatory = $true)] | |
[String] | |
$FilePath, | |
[parameter(Mandatory = $true)] | |
[Switch] | |
$PassThru | |
) | |
$secure = Read-Host -AsSecureString "Enter your Azure organization ID password." | |
$encrypted = ConvertFrom-SecureString -SecureString $secure | |
$result = Set-Content -Path $FilePath -Value $encrypted -PassThru | |
if (!$result) | |
{ | |
throw "Failed to store encrypted string at $FilePath." | |
} | |
if ($PassThru) | |
{ | |
dir $FilePath | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment