- 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
What is PowerShell Break statement?
The break statement in PowerShell is useful for terminating the loop. When the break statement is executed inside the inner loop, it terminates that particular loop execution and when it is placed in the outer loop, it terminates the entire loop including child loop(s).
Break statement is used with Foreach, For, While, Do-While and the Switch statement. When the break statement is used with the Label, PowerShell executes the label loop instead of exiting from the loop.
Break Statement example
$i = 1 While($i -ne 10){ Write-Output $i if($i -eq 5){break} $i++ }
Output
1 2 3 4 5
In the above example, the loop terminates when the value reaches 5 because the Break statement is executed.
- Related Articles
- How to use PowerShell break statement in foreach loop?
- What is break statement in JavaScript?
- How to use PowerShell Break statement with the While Loop?
- How to use PowerShell break statement with the For loop?
- How to use PowerShell Break statement with the Switch command?
- PHP break Statement
- What is a break statement in Java and how to use it?
- Java break statement with switch
- Break Statement in C/C++
- Break statement in Dart Programming
- Break statement in Lua Programming
- How to use PowerShell Break with the Label.
- Can we use break statement in a Python if clause?
- How can I use a label with break statement in JavaScript?
- What is Array in PowerShell?

Advertisements