added boolean conversion helper and replaced code in scripts to use it

This commit is contained in:
2026-10-01 11:16:23 -04:00
parent 2efb7116d8
commit a53dcfb6a9
5 changed files with 143 additions and 12 deletions
+4 -12
View File
@@ -21,18 +21,10 @@ If ( [string]::IsNullOrWhiteSpace([string]$DSAManifestSource) ) {
}
# Normalize RMM text values without treating every nonempty string as true.
$DsaOptions = @{ Zip = $Zip; Upload = $Upload; DeleteAfterUpload = $DeleteAfterUpload }
ForEach ( $DsaOptionName in @('Zip', 'Upload', 'DeleteAfterUpload') ) {
$DsaOptionValue = ([string]$DsaOptions[$DsaOptionName]).Trim().ToLowerInvariant()
If ( $DsaOptionValue -in @('true', '$true', 'yes', 'y', '1') ) {
$DsaOptions[$DsaOptionName] = $true
}
ElseIf ( $DsaOptionValue -in @('', 'false', '$false', 'no', 'n', '0') ) {
$DsaOptions[$DsaOptionName] = $false
}
Else {
Throw ('Invalid ${0} value. Use true, $true, yes, y, 1, false, $false, no, n, or 0.' -f $DsaOptionName)
}
$DsaOptions = @{
Zip = ConvertTo-RmmBoolean -Value $Zip -VariableName 'Zip'
Upload = ConvertTo-RmmBoolean -Value $Upload -VariableName 'Upload'
DeleteAfterUpload = ConvertTo-RmmBoolean -Value $DeleteAfterUpload -VariableName 'DeleteAfterUpload'
}
$DsaZipEnabled = $DsaOptions.Zip