This post is part of the series on PowerShell Snippets.
In this last post, in this series, I showed a PowerShell snippet which would prompt a user for input. This is fine if you are prompting for a username, filename, version tag or similar, but if you are prompting for a password, you would not want to expose to people watching over the users shoulder.
The Read-Host
cmdlet has a parameter which will allow for secure prompting of passwords:
$Password = Read-Host "Enter your password" -AsSecureString
Adding the AsSecureString
parameter will prompt for the password with a popup input box which obscures the password during entry.