powershell - How do you test for parallel conditions in a switch statement? -
I have read in different sources that the SWIFCH statement receives better performance compared to multiple IF statements. Do I have the following blocks of IF statements that have parallel conditions? Is it possible to do this SWITCH block? if ($ statusCode -q "OK:") -and ($ messageOutput) {$ returnValue = 0 return $ returnValue} if ($ StatusCode -q "Warning:") - And ($ messageOutput) {$ returnValue = 1 return $ returnValue} Thanks in advance, You have a constant that is $ messageOutput , so conditions are not actually parallel you can: if ($ messageOutput) {switch ($ statusCode) {" OK: "{0}" warning: "{1} default {1}}} It will be more efficient because you have to There is no need to check each variable again.