ah, figate! figate che nello scripting tradizionale, intendo nella shell , nel “prompt di dos” tradizionale ti dovevi fare in altri modi scomodi… evviva!!🙂

Richard Siddaway's Blog

I’ve posted about the switch statement a number of times but it is one of those topics that keeps coming up. Imagine you have a variable that can take one of several values. Depending on the value you might want to perform different actions like this

"red","blue","white","black","green","yellow"|foreach{$colour=$_if($colour-eq"red"){Write-host"Apples can be red"}if($colour-eq"blue"){Write-host"Balloons can be blue"}if($colour-eq"white"){Write-host"Snow can be white"}if($colour-eq"black"){Write-host"Coal can be black"}if($colour-eq"green"){Write-host"Grass can be green"}if($colour-eq"yellow"){Write-host"Custard can be yellow"}}

This is a whimsical example but my excuse…

View original post 552 altre parole