I'm have a small launcher windows app in c# that runs powershell scripts. They are being called as follow:
var ps1File = @"DBScripter.ps1";
var ticketname = this.txtTicketName.Text;
var startInfo = new ProcessStartInfo()
{
FileName = "powershell.exe",
Arguments = $"-NoProfile -ExecutionPolicy unrestricted -file \"{ps1File}\" -TicketName \"{ticketname}\"",
UseShellExecute = false
};
Process.Start(startInfo);
This is working fine, but if I add a non-mandatory boolean param to the call like this:
var ps1File = @"DBScripter.ps1";
var ticketname = this.txtTicketName.Text;
bool release = true;
var startInfo = new ProcessStartInfo()
{
FileName = "powershell.exe",
Arguments = $"-NoProfile -ExecutionPolicy unrestricted -file \"{ps1File}\" -TicketName \"{ticketname}\" -IsProdRelease \"{release}\"",
UseShellExecute = false
};
Process.Start(startInfo);
This does not work, whether I send a boolean, a string with $True or $true or an Integer with 1.
In the PS script, parameters are declared as follow:
param (
[Parameter(Mandatory = $false)]
[string]$TicketName,
[Parameter(Mandatory = $false)]
[string]$TicketPath,
[Parameter(Mandatory = $false)]
[boolean]$IsProdRelease
)
How should I pass this value from c# to the PS file execution?