WEBVTT

00:03.040 --> 00:07.840
The switch construct is somewhat similar to an F construct that has multiple allusive sections.

00:08.740 --> 00:14.680
The switch construct accepts a single value or a variable that contains a value or a property that contains

00:14.680 --> 00:15.250
a value.

00:16.090 --> 00:21.770
It compares that value to one of several possibilities that you provide when it finds a match.

00:21.790 --> 00:24.310
It executes the corresponding script block.

00:25.150 --> 00:28.750
A default section will execute only if no other matches were made.

00:29.620 --> 00:30.490
For example.

00:31.340 --> 00:37.460
Dollar drive equals get see I am instance class name when 32 underscore logical disk filter device id

00:37.580 --> 00:41.510
equal c switch dollar drive dot drive type.

00:42.410 --> 00:43.880
Three rate fixed local.

00:44.850 --> 00:45.330
Five.

00:45.360 --> 00:45.680
Right.

00:45.690 --> 00:46.230
Optical.

00:47.130 --> 00:48.450
Default write other.

00:49.320 --> 00:55.080
The switch construct can also match by using wildcard patterns, regular expressions and so on.

00:55.890 --> 01:00.750
To do this, you must specify a parameter that tells the construct what kind of match you want.

01:01.650 --> 01:06.930
For information about the available options, run help about underscore switch in Windows PowerShell.

01:07.800 --> 01:10.410
The construct differs from if in one important way.

01:11.230 --> 01:16.660
It will execute each matching script block instead of executing only the first matching condition.

01:17.530 --> 01:25.930
For example, dollar name equals get content EMV backslash computer name switch wild card dollar name

01:26.770 --> 01:28.930
law underscore ACL one asterisk.

01:29.830 --> 01:30.160
Right.

01:30.160 --> 01:32.440
Computer is a client lol.

01:32.530 --> 01:33.250
An asterisk.

01:34.160 --> 01:34.520
Right.

01:34.520 --> 01:35.930
Computer is in low end.

01:36.770 --> 01:37.370
Asterisk.

01:37.370 --> 01:38.480
DC Asterisk.

01:39.440 --> 01:39.770
Right.

01:39.770 --> 01:41.180
Computer is a DC.

01:42.020 --> 01:43.040
Asterisk one.

01:43.980 --> 01:44.310
Right.

01:44.310 --> 01:47.160
Computer is the first one default.

01:48.060 --> 01:48.380
Right.

01:48.390 --> 01:49.110
No matches.

01:49.980 --> 01:55.620
In this example, ELO and Ciel one will display both computer is a client and computer is the first

01:55.620 --> 01:57.450
one because both conditions match.

01:58.320 --> 02:01.050
You can use the break keyword to exit the construct.

02:01.950 --> 02:05.520
This prevents multiple matches, for example.

02:06.360 --> 02:14.810
Dollar name equals get content EMV backslash computer name switch wild card dollar name loan underscore

02:14.820 --> 02:16.080
seal one asterisk.

02:16.950 --> 02:19.890
Right computer is a client Drake.

02:20.770 --> 02:21.000
LOL.

02:21.040 --> 02:21.730
An asterisk.

02:22.650 --> 02:23.010
Right.

02:23.010 --> 02:24.660
Computer is in NYC.

02:25.530 --> 02:26.130
Asterisk.

02:26.130 --> 02:27.240
DC Asterisk.

02:28.210 --> 02:28.540
Right.

02:28.540 --> 02:31.270
Computer is a DC Drake.

02:32.170 --> 02:33.160
Asterisk one.

02:34.110 --> 02:34.440
Right.

02:34.440 --> 02:37.290
Computer is the first one default.

02:38.190 --> 02:38.520
Right.

02:38.520 --> 02:39.240
No matches.

02:40.110 --> 02:43.770
L0 and l one will now display only computer is a client.

02:44.670 --> 02:50.520
The computer elo and DC one would display computer is in NYC and computer is a DC.
