Security.SecureString parameter does not accept strings
You can't pass a string; you have to pass a secure string
function Get-PasswordThing { Param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [Security.SecureString]$password=$(Throw "Password required.") ) Process { Write-Host "cool" }}[string]$password = "hello"[Security.SecureString]$securePassword = ConvertTo-SecureString $password -AsPlainText -ForceGet-PasswordThing -password $securePassword# inlineGet-PasswordThing -password (ConvertTo-SecureString $password -AsPlainText -Force)
Another option is to take the password as a String and then convert it to a SecureString within your function.
Function DoSomething {Param ( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [String]$password=$(Throw "Password required."))$password = $password | ConvertTo-SecureString -AsPlainText -Force#your script continues here}