Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Yes, All
#region Test-YesAllConfirm
function Test-YesAllConfirm {
[CmdletBinding()]
param(
[int[]]$Numbers
)
process {
foreach ($num in $Numbers) {
if (-not $doAll) {
$keepGoing = Read-Host "Are you sure you want to process: [$num] (Yes, No, All (default), Exit)"
switch -Regex ($keepGoing) {
'Yes' { "Current number: [$num]" }
'No' { break }
'Exit' { return }
Default {
$doAll = $true
"Current number: [$num]"
}
}
} else {
"Current number: [$num]"
}
}
}
}
Test-YesAllConfirm -Numbers $Numbers
#endregion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.