added boolean conversion helper and replaced code in scripts to use it
This commit is contained in:
+4
-12
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user