Assume I have a custom PowerShell Cmdlet that exports data and encrypts it using a password.
[Cmdlet(VerbsData.Export, \"SampleData\")]
public class ExportSample
If you are writing a C# PowerShell Cmdlet and one of the parameters requires the user to enter a password it should be obfuscated.
To do this you need to be using System.Security;
And then your parameter type should be SecureString.
So using your example:
[Cmdlet(VerbsData.Export, "SampleData")]
public class ExportSampleData : PSCmdlet
{
[Parameter(Mandatory = true)]
public SecureString Password
{
get;
set;
}
/* additional parameters */
}