Last active
May 1, 2019 07:07
-
-
Save PrzemyslawKlys/31939e0222bb313c68aa79d7c6c38203 to your computer and use it in GitHub Desktop.
Testing break on Begin/process/End
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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