If you need to prompt for a secret password and do not want it to be visible while entered, you should use Get-Credential. This cmdlet returns a credential object, which contains the entered password in encrypted format. You should then call GetNetworkCredential() to un-encrypt it to plain text:
$cred = Get-Credential SomeUserName
$cred.Password
System.Security.SecureString
$cred.GetNetworkCredential()
UserName Password Domain
-------- -------- ------
SomeUserName secret
$cred.GetNetworkCredential().Password
secret
ReTweet this Tip!
Posted
Sep 22 2010, 08:01 AM
by
ps1