Save-PasswordFile.ps1
something exciting
Some information about the exciting thing
Table of contents generated with markdown-toc
Script
function Save-PasswordFile {
<# Example
.EXAMPLE
Save-Password -Label UserName
.EXAMPLE
Save-Password -Label Password
#>
param(
[Parameter(Mandatory = $true,
HelpMessage = "Enter password label")]
[string]$Label,
[Parameter(Mandatory = $false,
HelpMessage = "Enter file path.")]
[ValidateSet('Profile', 'Select') ]
[string]$Path
)
switch ($Path) {
Profile {
$ProfilePath = ($PROFILE).Split('\Microsoft.PowerShell_profile.ps1')[0]
$filePath = "$ProfilePath" + "\$Label.txt"
$securePassword = Read-host -Prompt 'Input password' -AsSecureString | ConvertFrom-SecureString
$securePassword | Out-File -FilePath "$filePath"
}
Select {
$directoryPath = Select-FolderLocation
$securePassword = Read-host -Prompt 'Input password' -AsSecureString | ConvertFrom-SecureString
$securePassword | Out-File -FilePath "$directoryPath\$Label.txt"
}
Default {
$ProfilePath = ($PROFILE).Split('\Microsoft.PowerShell_profile.ps1')[0]
$filePath = "$ProfilePath" + "\$Label.txt"
$securePassword = Read-host -Prompt 'Input password' -AsSecureString | ConvertFrom-SecureString
$securePassword | Out-File -FilePath "$filePath"
}
}
}
Download
Please feel free to copy parts of the script or if you would like to download the entire script, simple click the download button. You can download the complete repository in a zip file by clicking the Download link in the menu bar on the left hand side of the page.
Report Issues
You can report an issue or contribute to this site on GitHub. Simply click the button below and add any relevant notes. I will attempt to respond to all issues as soon as possible.