PowerShell Snippets: Prompt User for Password

PowerShellThis 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.

What should we write about next?

If there is a topic which fits the typical ones of this site, which you would like to see me write about, please use the form, below, to submit your idea.

Your Name

Your Email

Suggested Topic

Suggestion Details

Leave a Reply

Your email address will not be published. Required fields are marked *