Entering Passwords Securely

by Feb 4, 2011

You can use Read-Host -asSecureString to be able to type a password with hidden characters:

$password = Read-Host -asSecureString 'Password'

This will return a secure string. You should use this to get the password back into plain text:

$password = (New-Object System.Management.AUtomation.PSCredential(
'dummy',(Read-Host -asSecureString 'Password')))
.GetNetworkCredential().password

Twitter This Tip!
ReTweet this Tip!