@@ -894,9 +894,13 @@ $OtherOperationsLast = [ordered]@{
894894 " Report" = " ${PSScriptRoot} \Report.ps1" , " Run the reporting script" ;
895895}
896896if ($IsDomainJoined ) {
897- Show-Output - ForegroundColor Cyan " You can safely ignore the `" key is not valid`" error below."
898- # Adding this does not help: -ErrorAction SilentlyContinue
899- $OtherOperations = Sort-Object ($OtherOperations + $OtherOperationsWork )
897+ # Sort-Object cannot be used directly on a dictionary,
898+ # as it would interpret the dictionary as a sorting rule instead of as input.
899+ $OtherOperationsMerged = $OtherOperations + $OtherOperationsWork
900+ $OtherOperations = [ordered ]@ {}
901+ foreach ($Key in ($OtherOperationsMerged.Keys | Sort-Object )) {
902+ $OtherOperations [$Key ] = $OtherOperationsMerged [$Key ]
903+ }
900904}
901905$OtherOperations += $OtherOperationsLast
902906
@@ -1043,7 +1047,9 @@ function Get-SelectedCommands {
10431047 foreach ($row in $rows ) {
10441048 $commands += $row.Command ;
10451049 }
1046- return $commands ;
1050+ # The comma prevents PowerShell from unrolling the array,
1051+ # which would return $null for an empty array and a scalar for a single item.
1052+ return , $commands ;
10471053}
10481054
10491055function Select-Cells {
@@ -1230,15 +1236,15 @@ if (! $Form.Continue) {
12301236# ####
12311237
12321238$ChocoSelected = Get-SelectedCommands $ChocoProgramsView
1233- if ($ChocoSelected.Count ) {
1239+ if ($ChocoSelected.Count -gt 0 ) {
12341240 Show-Output " Installing $ ( $ChocoSelected.Count ) program(s) with Chocolatey."
12351241 choco upgrade - y $ChocoSelected
12361242} else {
12371243 Show-Output " No programs were selected to be installed with Chocolatey."
12381244}
12391245
12401246$WingetSelected = Get-SelectedCommands $WingetProgramsView
1241- if ($WingetSelected.Count ) {
1247+ if ($WingetSelected.Count -gt 0 ) {
12421248 Show-Output " Installing $ ( $WingetSelected.Count ) program(s) with Winget. If asked to accept the license of the package repository, please select yes."
12431249 foreach ($Program in $WingetSelected ) {
12441250 winget install " ${Program} "
@@ -1248,7 +1254,7 @@ if ($WingetSelected.Count) {
12481254}
12491255
12501256$WindowsCapabilitiesSelected = Get-SelectedCommands $WindowsCapabilitiesView
1251- if ($WindowsCapabilitiesSelected.Count ) {
1257+ if ($WindowsCapabilitiesSelected.Count -gt 0 ) {
12521258 Show-Output " Installing $ ( $WindowsCapabilitiesSelected.Count ) Windows capabilitie(s)."
12531259 foreach ($Capability in $WindowsCapabilitiesSelected ) {
12541260 Show-Output " Installing ${Capability} "
@@ -1259,7 +1265,7 @@ if ($WindowsCapabilitiesSelected.Count) {
12591265}
12601266
12611267$WindowsFeaturesSelected = Get-SelectedCommands $WindowsFeaturesView
1262- if ($WindowsFeaturesSelected.Count ) {
1268+ if ($WindowsFeaturesSelected.Count -gt 0 ) {
12631269 Show-Output " Installing $ ( $WindowsFeaturesSelected.Count ) Windows feature(s)."
12641270 foreach ($Feature in $WindowsFeaturesSelected ) {
12651271 Show-Output " Installing ${Feature} "
@@ -1272,7 +1278,7 @@ if ($WindowsFeaturesSelected.Count) {
12721278# These have to be after the package manager -based installations,
12731279# as the package managers may install some Visual C++ runtimes etc., which we want to update automatically.
12741280$OtherSelected = Get-SelectedCommands $OtherOperationsView
1275- if ($OtherSelected.Count ) {
1281+ if ($OtherSelected.Count -gt 0 ) {
12761282 Show-Output " Running $ ( $OtherSelected.Count ) other selected operation(s)."
12771283 foreach ($Command in $OtherSelected ) {
12781284 try {
0 commit comments