07-21-2023, 04:00 PM
I coincidentally found out that <code>Break <i>&lt;UnknownLabel&gt;</i></code> (e.g. simply <code>Break <b>Script</b></code>, *where the label `Script` doesn't exists*) appears to break out of the entire script (even from within a function) and keeps the host alive.
This way you could create a function that breaks the script from anywhere (e.g. a recursive loop) without knowing the current scope (and creating labels):
Function Quit($Text) {
Write-Host "Quiting because: " $Text
Break Script
}
This way you could create a function that breaks the script from anywhere (e.g. a recursive loop) without knowing the current scope (and creating labels):
Function Quit($Text) {
Write-Host "Quiting because: " $Text
Break Script
}