Powershell: Why is my variable empty after using ForEach-Object -Parallel?

I am trying to gather data from several servers using ForEach-Object -Parallel. The variable I use is being populated within the loop, but when the loop finishes the variable is empty. $DBDetails = "SELECT @@VERSION" $VMs = ("vm1", "vm2", "vm3", "vm4", "vm5", "vm6", "vm7") $DBInventory = @() $scriptBlock = { $vm = $_ $result =… Read More Powershell: Why is my variable empty after using ForEach-Object -Parallel?

How do I do foreach loop with a where clause for a multidimensional array in Powershell?

For example $people = @( @(‘adam’, ’24’, ‘M’) @(‘andy’, ’20’, ‘M’) @(‘alex’, ’30’, ‘M’) @(‘ava’, ’25’, ‘F’) ) foreach($person in $people | where ($person[1] -lt ’25’) -and ($person[2] -eq ‘M’)) and this should select adam and andy… >Solution : The syntax you should use for your Where-Object statement would be: $people = @( @(‘adam’, ’24’,… Read More How do I do foreach loop with a where clause for a multidimensional array in Powershell?