VMware Cloud Community
drivera01
Enthusiast
Enthusiast

case statements in powercli

are they possible?

Im use to doing items like this in shell scripting.

I was wondering if there is an equivelant in powercli?

case "$1" in
'"item1')
        something here
        ;;

"item2'')
        something here
        ;;
*)
        echo "Usage: { item1 | item2 }"
        ;;
esac
exit 0

0 Kudos
2 Replies
LucD
Leadership
Leadership

It's nearly the same, just a few differences in syntax

$var = "xyz"

switch($var){     'item1' {         "Something for item1"
    }    
'item2' {         "Something for item2"
    }     Default {         "Usage: {item1 | item2}"
    } }

For all the Switch details, do a

Get-Help About_switch


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
drivera01
Enthusiast
Enthusiast

Hi LucD,

thanks for the info!!

0 Kudos