The Deployment Bunny

OS Deployment, Virtualization, Microsoft based Infrastructure…

  • Archives

  • Meta

PowerShell is King – Working with Passwords, Secure Strings and Credentials

Posted by Mikael Nystrom on December 6, 2014

No, not something new at all, more of a answer on a lot of questions I got from folks. At TechNet Wiki there is a page that describes how to deal with passwords, secure strings and such.

Working with Passwords, Secure Strings and Credentials in Windows PowerShell

Here is the most common I use:

Create SecureString

Type the password in an interactive prompt:

$SecurePassword = Read-Host -Prompt “Enter password” -AsSecureString

Convert from existing plaintext variable

$PlainPassword = “P@ssw0rd”
$SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force

Create PSCredentials

Assuming that you have password in SecureString form in $SecurePassword variable:

$UserName = “Domain\User”
$Credentials = New-Object System.Management.Automation.PSCredential -ArgumentList $UserName, $SecurePassword

Read the rest of the Wiki here: http://social.technet.microsoft.com/wiki/contents/articles/4546.working-with-passwords-secure-strings-and-credentials-in-windows-powershell.aspx

/mike

5 Responses to “PowerShell is King – Working with Passwords, Secure Strings and Credentials”

  1. Magnus Jägre said

    Länken verkar vara kaputt :-(

  2. Jeff said

    You should really blank out the clear text password after it’s converted so it’s not stored in memory.

  3. You should really blank it the clear text password after conversion so it’s not stored in memory.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: