String '$false' was not recognized as a valid Boolean

Hey gang,

I was getting this particular error on 2.10 but didn’t post about it because we were planning a 3.1.0 upgrade, but the error persists post update.

I have a script with the following parameters:

param(
    [Parameter(Mandatory)]
    [string]$Room,

    [Parameter(Mandatory)]
    [string]$GroupTag,

    [bool]$Wipe = $false
)

… and I am able to execute that script no problem from a dashboard.

When I try to execute it from the scripts page, I get the normal dialog popping up:

… but then when I click OK, I get an error toast:

image

… and this message is in the PSU log file:

System.FormatException: String '$false' was not recognized as a valid Boolean.
   at System.Boolean.Parse(ReadOnlySpan`1 value)
   at System.Boolean.Parse(String value)
   at UniversalAutomation.ScriptParameterParser.SerializeParameter(JobParameter parameter) in C:\actions-runner\_work\universal\universal\src\Universal.Server\Utilities\ScriptParameterParser.cs:line 56
   at PowerShellUniversal.Client.InvokeScript(JobContext jobContext) in C:\actions-runner\_work\universal\universal\src\Universal.Server\Services\Client.cs:line 592
   at UniversalAutomation.ScriptController.InvokeScriptByPath(String scriptFullPath, JobContext jobContext) in C:\actions-runner\_work\universal\universal\src\Universal.Server\Controllers\ScriptController.cs:line 198

Am I doing something wrong with my Boolean parameter? PSU is clever enough to render it as a switch control in the run dialog, but then has trouble parsing it for some reason.

Cheers,
Matt

Product: PowerShell Universal
Version: 3.1.0

I don’t think it’s properly handling default values for bools. I’ll open an issue for this.

1 Like