Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
adbertram committed Mar 20, 2018
1 parent 5f72970 commit f88241b
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Random Stuff/Confirm-Choice.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
function Confirm-Choice {
[OutputType('boolean')]
[CmdletBinding()]
param
(
[Parameter()]
[ValidateNotNullOrEmpty()]
[string]$Title,

[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string]$PromptMessage
)

$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes"
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No"
$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)

if ($PSBoundParameters.ContainsKey('Title')) {
Write-Host -Object $Title -ForegroundColor Cyan
}

Write-Host -Object $PromptMessage -ForegroundColor Cyan
$result = $host.ui.PromptForChoice($null, $null, $Options, 1)

switch ($result) {
0 {
$true
}
1 {
$false
}
}
}

0 comments on commit f88241b

Please sign in to comment.