- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to use PowerShell Break statement with the Switch command?
In Switch command, when the single value passed and if it matches the condition then the loop gets automatically exited but when there are multiple values passed and if the value matches the first condition and if you want to terminate the loop then you can use the Break statement. An example is given below.
Example
Switch (3,5){ 1 {"This is One"} 2 {"This is Two"} 3 {"This is Three"; Break} 4 {"This is Four"} 5 {"This is Five"; Break} }
Output
This is Three
You can notice in the above output that second parameter 5 won’t be executed because the 3 has already been executed with the break statement.
- Related Articles
- How to use PowerShell Break statement with the While Loop?
- How to use PowerShell break statement with the For loop?
- Java break statement with switch
- How to use PowerShell break statement in foreach loop?
- How to use PowerShell Break with the Label.
- What is PowerShell Break statement?
- How to use the Timeout command in PowerShell?
- How to use the tree command in PowerShell?
- How to use the Set-Location command in PowerShell?
- How to use Split-Path command in PowerShell?
- How can I use a label with break statement in JavaScript?
- How to use the ConvertFrom-StringData command in PowerShell?\n
- How to use strings in switch statement in C#
- Can we use Switch statement with Strings in java?
- How to use the break statement to come out of a loop in JavaScript?

Advertisements