Powershell convert to SecureString

3.9k Views Asked by At

This is what I'm working on

$First = Read-Host "Enter First Name"
$Last = Read-Host "Enter Last Name"
$FirstIntitial = $First.Substring(0,1)
$LastInitial = $Last.Substring(0,1)
$FirstLastInitial = $FirstIntitial.ToUpper()+$LastInitial.ToUpper()
$Location = Read-Host "Enter Location"
$Department = Read-Host "Enter Department"
$Database
$Password = $FirstLastInitial+"Company"
Write-Host $Password
$SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force

When i run it I get the error:

"Cannot process argument transformation on parameter 'Password'. Cannot convert the "System.Security.SecureString" value of type "System.String" to type "System.Security.SecureString"

Im very new to powershell and this is written based on what ive found on google. How am I supposed to convert the password to a securestring?

0

There are 0 best solutions below