There are multiple arrays, and their contents might or might not be empty. If any of these arrays are empty, I would like to add a default value to them.
I have tried wrapping all the arrays into a container array and using Foreach-Object, but the default value does not appear to be assigned.
#...
$arr1 = @()
$arr2 = @("a","b")
$arr3 = @("c","d")
@($arr1, $arr2, $arr3 | ForEach-Object {
if($_.Count -le 0) {
$_ = @("EMPTY")
}
})
Write-Output $arr1
# ...
The empty array was not assigned
PS> $arr1
PS> <# NOTHING #>
Is it possible to set a default value for those arrays?