What is the difference between the keywords Exit, Return and Break in PowerShell?
What does each exactly do?
- Break terminates execution of a loop or switch statement and hands over control to next statement after it.
- Return terminates execution of the current function and passes control to the statement immediately after the function call.
- Exit terminates the current execution session altogether. It also closes the console window and may or may not close ISE depending on what direction the wind is facing.
Not sure I get it yet…
Can you provide some examples?
Sure thing, let’s look at an example for each one.