It's a little hard to decipher what you're trying to do...
Edit; like mentioned by Ryan, you currently already are specifying it as a string...
But in some code, I've used the following function when using Read-Host and SecureStrings
function AskSecureQ ([String]$Question, [String]$Foreground="Yellow", [String]$Background="Blue") {
Write-Host $Question -ForegroundColor $Foreground -BackgroundColor $Background -NoNewLine
Return (Read-Host -AsSecureString)
}
In your case you'd call it by doing the following;
Param (
[Parameter(Mandatory=$True)]
[string]$FileLocation,
[Parameter(Mandatory=$True)]
[string]$password = AskSecureQ "Type the password you would like to set all the users to"
)
EDIT: Given comments, and just for the hell of it... here's an alternative method used to convert the above secure string into plain text within Powershell;
# Taking a secure password and converting to plain text
Function ConvertTo-PlainText( [security.securestring]$secure ) {
$marshal = [Runtime.InteropServices.Marshal]
$marshal::PtrToStringAuto( $marshal::SecureStringToBSTR($secure) )
}
You'd use it like this;
$PWPlain = ConvertTo-PlainText $password
Too summarise, you take the password in masked, it's a secure string, you can then break this down into plain text for use elsewhere, a real word example would be if certain CLI programs only accept passwords being passed into them as plain text, this helps with automation where you don't want to hard code a password into your script..