Last week I had a diner with a fellow Dutch IT professional where eventually PowerShell was brought up, specifically the *switch* statement.

Ernst (the name of that guy) told me that it was not possible to make a switch compare against more than 256 options, I said that it was possible.

To make things more interesting, I told him that I was willing to bet a crate of beer for it… and the fool accepted! **Note: **You have to know that if I’m willing to bet food or drinks on something, I’m very sure that I’m right

Just now I’ve done some ‘switching’ and confirmed that I was right… __Ernst… I’ll take those beers now, thank you very much! __

__Here’s the code: __* function Slap-Ernst ($param) { switch ($param) { 1 {"The number is 1"} 2 {"The number is 2"} 3 {"The number is 3"} 4 {"The number is 4"} 5 {"The number is 5"} 6 {"The number is 6"} 7 {"The number is 7"} 8 {"The number is 8"} 9 {"The number is 9"} 10 {"The number is 10"} 11 {"The number is 11"} 12 {"The number is 12"} 13 {"The number is 13"} 14 {"The number is 14"} 15 {"The number is 15"} 16 {"The number is 16"} 17 {"The number is 17"} 18 {"The number is 18"} 19 {"The number is 19"} 20 {"The number is 20"} 21 {"The number is 21"} 22 {"The number is 22"} 23 {"The number is 23"} 24 {"The number is 24"} 25 {"The number is 25"} 26 {"The number is 26"} 27 {"The number is 27"} 28 {"The number is 28"} 29 {"The number is 29"} 30 {"The number is 30"} 31 {"The number is 31"} 32 {"The number is 32"} 33 {"The number is 33"} 34 {"The number is 34"} 35 {"The number is 35"} 36 {"The number is 36"} 37 {"The number is 37"} 38 {"The number is 38"} 39 {"The number is 39"} 40 {"The number is 40"} 41 {"The number is 41"} 42 {"The number is 42"} 43 {"The number is 43"} 44 {"The number is 44"} 45 {"The number is 45"} 46 {"The number is 46"} 47 {"The number is 47"} 48 {"The number is 48"} 49 {"The number is 49"} 50 {"The number is 50"} 51 {"The number is 51"} 52 {"The number is 52"} 53 {"The number is 53"} 54 {"The number is 54"} 55 {"The number is 55"} 56 {"The number is 56"} 57 {"The number is 57"} 58 {"The number is 58"} 59 {"The number is 59"} 60 {"The number is 60"} 61 {"The number is 61"} 62 {"The number is 62"} 63 {"The number is 63"} 64 {"The number is 64"} 65 {"The number is 65"} 66 {"The number is 66"} 67 {"The number is 67"} 68 {"The number is 68"} 69 {"The number is 69"} 70 {"The number is 70"} 71 {"The number is 71"} 72 {"The number is 72"} 73 {"The number is 73"} 74 {"The number is 74"} 75 {"The number is 75"} 76 {"The number is 76"} 77 {"The number is 77"} 78 {"The number is 78"} 79 {"The number is 79"} 80 {"The number is 80"} 81 {"The number is 81"} 82 {"The number is 82"} 83 {"The number is 83"} 84 {"The number is 84"} 85 {"The number is 85"} 86 {"The number is 86"} 87 {"The number is 87"} 88 {"The number is 88"} 89 {"The number is 89"} 90 {"The number is 90"} 91 {"The number is 91"} 92 {"The number is 92"} 93 {"The number is 93"} 94 {"The number is 94"} 95 {"The number is 95"} 96 {"The number is 96"} 97 {"The number is 97"} 98 {"The number is 98"} 99 {"The number is 99"} 100 {"The number is 100"} 101 {"The number is 101"} 102 {"The number is 102"} 103 {"The number is 103"} 104 {"The number is 104"} 105 {"The number is 105"} 106 {"The number is 106"} 107 {"The number is 107"} 108 {"The number is 108"} 109 {"The number is 109"} 110 {"The number is 110"} 111 {"The number is 111"} 112 {"The number is 112"} 113 {"The number is 113"} 114 {"The number is 114"} 115 {"The number is 115"} 116 {"The number is 116"} 117 {"The number is 117"} 118 {"The number is 118"} 119 {"The number is 119"} 120 {"The number is 120"} 121 {"The number is 121"} 122 {"The number is 122"} 123 {"The number is 123"} 124 {"The number is 124"} 125 {"The number is 125"} 126 {"The number is 126"} 127 {"The number is 127"} 128 {"The number is 128"} 129 {"The number is 129"} 130 {"The number is 130"} 131 {"The number is 131"} 132 {"The number is 132"} 133 {"The number is 133"} 134 {"The number is 134"} 135 {"The number is 135"} 136 {"The number is 136"} 137 {"The number is 137"} 138 {"The number is 138"} 139 {"The number is 139"} 140 {"The number is 140"} 141 {"The number is 141"} 142 {"The number is 142"} 143 {"The number is 143"} 144 {"The number is 144"} 145 {"The number is 145"} 146 {"The number is 146"} 147 {"The number is 147"} 148 {"The number is 148"} 149 {"The number is 149"} 150 {"The number is 150"} 151 {"The number is 151"} 152 {"The number is 152"} 153 {"The number is 153"} 154 {"The number is 154"} 155 {"The number is 155"} 156 {"The number is 156"} 157 {"The number is 157"} 158 {"The number is 158"} 159 {"The number is 159"} 160 {"The number is 160"} 161 {"The number is 161"} 162 {"The number is 162"} 163 {"The number is 163"} 164 {"The number is 164"} 165 {"The number is 165"} 166 {"The number is 166"} 167 {"The number is 167"} 168 {"The number is 168"} 169 {"The number is 169"} 170 {"The number is 170"} 171 {"The number is 171"} 172 {"The number is 172"} 173 {"The number is 173"} 174 {"The number is 174"} 175 {"The number is 175"} 176 {"The number is 176"} 177 {"The number is 177"} 178 {"The number is 178"} 179 {"The number is 179"} 180 {"The number is 180"} 181 {"The number is 181"} 182 {"The number is 182"} 183 {"The number is 183"} 184 {"The number is 184"} 185 {"The number is 185"} 186 {"The number is 186"} 187 {"The number is 187"} 188 {"The number is 188"} 189 {"The number is 189"} 190 {"The number is 190"} 191 {"The number is 191"} 192 {"The number is 192"} 193 {"The number is 193"} 194 {"The number is 194"} 195 {"The number is 195"} 196 {"The number is 196"} 197 {"The number is 197"} 198 {"The number is 198"} 199 {"The number is 199"} 200 {"The number is 200"} 201 {"The number is 201"} 202 {"The number is 202"} 203 {"The number is 203"} 204 {"The number is 204"} 205 {"The number is 205"} 206 {"The number is 206"} 207 {"The number is 207"} 208 {"The number is 208"} 209 {"The number is 209"} 210 {"The number is 210"} 211 {"The number is 211"} 212 {"The number is 212"} 213 {"The number is 213"} 214 {"The number is 214"} 215 {"The number is 215"} 216 {"The number is 216"} 217 {"The number is 217"} 218 {"The number is 218"} 219 {"The number is 219"} 220 {"The number is 220"} 221 {"The number is 221"} 222 {"The number is 222"} 223 {"The number is 223"} 224 {"The number is 224"} 225 {"The number is 225"} 226 {"The number is 226"} 227 {"The number is 227"} 228 {"The number is 228"} 229 {"The number is 229"} 230 {"The number is 230"} 231 {"The number is 231"} 232 {"The number is 232"} 233 {"The number is 233"} 234 {"The number is 234"} 235 {"The number is 235"} 236 {"The number is 236"} 237 {"The number is 237"} 238 {"The number is 238"} 239 {"The number is 239"} 240 {"The number is 240"} 241 {"The number is 241"} 242 {"The number is 242"} 243 {"The number is 243"} 244 {"The number is 244"} 245 {"The number is 245"} 246 {"The number is 246"} 247 {"The number is 247"} 248 {"The number is 248"} 249 {"The number is 249"} 250 {"The number is 250"} 251 {"The number is 251"} 252 {"The number is 252"} 253 {"The number is 253"} 254 {"The number is 254"} 255 {"The number is 255"} 256 {"The number is 256"} 257 {"The number is 257"} 258 {"The number is 258"} 259 {"The number is 259"} 260 {"The number is 260"} 261 {"The number is 261"} 262 {"The number is 262"} 263 {"The number is 263"} 264 {"The number is 264"} 265 {"The number is 265"} 266 {"The number is 266"} 267 {"The number is 267"} 268 {"The number is 268"} 269 {"The number is 269"} 270 {"The number is 270"} 271 {"The number is 271"} 272 {"The number is 272"} 273 {"The number is 273"} 274 {"The number is 274"} 275 {"The number is 275"} 276 {"The number is 276"} 277 {"The number is 277"} 278 {"The number is 278"} 279 {"The number is 279"} 280 {"The number is 280"} 281 {"The number is 281"} 282 {"The number is 282"} 283 {"The number is 283"} 284 {"The number is 284"} 285 {"The number is 285"} 286 {"The number is 286"} 287 {"The number is 287"} 288 {"The number is 288"} 289 {"The number is 289"} 290 {"The number is 290"} 291 {"The number is 291"} 292 {"The number is 292"} 293 {"The number is 293"} 294 {"The number is 294"} 295 {"The number is 295"} 296 {"The number is 296"} 297 {"The number is 297"} 298 {"The number is 298"} 299 {"The number is 299"} 300 {"The number is 300"} } }*

I hope you used PowerShell to write that function.

I admit that I’m crazy, but not crazy enough to type all of that manually 😉 No, a simple for-loop combined with write-output and copy-paste the output did the trick 🙂