Skip to content

Instantly share code, notes, and snippets.

@PrzemyslawKlys
Last active May 1, 2019 07:07
Show Gist options
  • Save PrzemyslawKlys/31939e0222bb313c68aa79d7c6c38203 to your computer and use it in GitHub Desktop.
Save PrzemyslawKlys/31939e0222bb313c68aa79d7c6c38203 to your computer and use it in GitHub Desktop.
Testing break on Begin/process/End
Clear-Host
Function Limit-BlockUsageOne {
[CmdletBinding()]
Param (
$Stop = 1
)
Begin {
if ($Stop -eq 2) {
break
}
$RandomNumber = Get-Random -Minimum 1 -Maximum 3
} # End Begin
Process {
If ($RandomNumber -eq 1) {
"Inside the Process block."
} # End If.
} # End Process.
End {
If ($RandomNumber -eq 1) {
"Inside the End block."
} # End If.
} # End End.
} # End Function: Limit-BlockUsageOne
1..10 | ForEach-Object {
"-----Execution # $_-----"
Limit-BlockUsageOne -Stop 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment