powershell - Checking for null arrays in an PSObject -
How do I check for an object or empty, which has multiple arrays? $ Buildings.north = {bld1, bld2, bld3} $ buildings.South = {} $ buildings.East = {bld5, bld6} $ buildings.West = {bld7, bld8, bld9
$ Buildings , Bld10} I started with if / elseif to go through each, but it would be 16 combinations:
if ($ buildings North Coat ount-AQ "0" - and $ Building. South Quint-I "$ 1" and $ Building. East Quant's "1" -And $ Building. West Control- "1" {Set-Function- OPT1 $ Building. South-OPT 2 Dollar Building. Est-Ofty $ Dollar Building.West} Otherwise ($ Building. Earth Count -ge "1" -And Building $. South Cout-C "1" - and $ Build East Count -ge "1" -and $ Building. West Seat-C "1") {Set Function -OPT1 $ Building. Upper-OPT 2 $ Building. South-OPT 3 $ Building.Aust-Off4 $ Building West} Otherwise ($ Buildings.No.co.uk - AQ "0" - And $ Building. South Cottage -Ek "0" - And $ Building. East Quant - AQ "0" - And $ Building.west .count -eq "0") {# is nothing to evacuate} otherwise ($ Buildings. North Quotation - EC "0" - and $ Buildings. South Coat -Ek "0" -and $ B Uildings.E Ast.count -ge "1" -and $ Building. West count -ge "1") {Set-Function- OPT3 $ Building. East-OPT 4 $ Building West} Since you can select hundreds of options in an object, it can be a lot of code I have also tried to exclude CMD from the string:
$ Cmd = '-Location $ Loc' if ($ Building .real count -ge "1") {$ cmd + = '-OPT1 $ Buildings.'} Otherwise ($ Building. South Quant -J " 1 ") {$ CMD + = '-OPT2 $ Building. South ') Otherwise ($ Building East Quant-Aid "1") {$ CMD + =' -OPT3 $ Building.Est '} Otherwise ($ Building. West count -ge "1") {$ Cmd + =' - OPT4 $ Buildings.West}} Set function $ CMD There is no success with this approach, there should be a better way to investigate this kind, help finding it at the most Will be appreciated
This should work:
$ CMD = '-place '$ Location' if ($ building .real count -ge "1") {$ cmd + = '-OPT1 `$ building ($ Buildings. East Count -ge" 1 ") $ {$ CMD} $. ($ Building. East Count -ge "1") ($ Buildings.South Count -ge "1") {$ cmd + = '-OPT2' $ buildings + = '-OPT3' $ buildings. East '} Otherwise ($ Building West count -ge "1") {$ CMD + =' -OPT4 '$ Building.West}} Invitation -Application "Set-Function $ cmd" < / Div>
Comments
Post a Comment