In my program I need to ask user for password in parameter:
[Cmdlet(VerbsCommon.Get, "MyTest"]
public class GetMyTest : PSCmdlet
{
[Parameter(Mandatory=true)]
public ? Password { get; set;}
}
I can't figure out what is the correct type to use for Password. In another question: How does one securely handle passwords in a custom written PowerShell cmdlet?
The accepted answer asked to use read-host in the code, but I have to use parameter to ask for this field.
I also tried to use SecureString for Password, but I am not able to give a SecureString to this parameter as it will be automatically accepted as string, not secure string.
Is it any way to achieve the following usage:
Get-MyTest -Password ***** (where I actually type in 'abcde' but the input is masked.)