From the course: PowerShell 7 Essential Training
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Switch statements - PowerShell Tutorial
From the course: PowerShell 7 Essential Training
Switch statements
- [Instructor] Now, there is another mechanism available to us. I'm just going to make some more space here, and we'll clear the bottom. The other option that will help us in flowing specific things, is what's referred to as a Switch Statement. Now, a switch statement allows me to say, pass a value into it, and the switch statement then determines what to do. So let me give you an idea of how this works. So, first off, I'm going to type in here. So this is value. I'm going to say, "Type your favorite car brand," and then we're going to check the value. Now, to validate the value that's been typed in, we're going to utilize a switch command. Now, I'm going to copy from the exercise file into here, just make it easier. So, I'm going to paste it in and you can see that it says, "Switch value", and then we have "Brand1, Brand2, Brand3, Brand4." Those are the values that the switch command is expecting. So let's select…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
PowerShell security6m 15s
-
(Locked)
Create your first script8m 30s
-
(Locked)
Parameter attributes for scripts and functions15m 16s
-
(Locked)
Select information10m 24s
-
(Locked)
Filter specific data10m 43s
-
(Locked)
Control the flow of PowerShell8m 31s
-
(Locked)
Ternary operators2m 39s
-
(Locked)
Switch statements3m 58s
-
(Locked)
Define custom help9m 22s
-
(Locked)
Distributing custom PowerShell scripts5m 42s
-
(Locked)
-
-
-