Skip to content

Instantly share code, notes, and snippets.

@kilasuit
Created March 12, 2020 22:59
Show Gist options
  • Save kilasuit/4fed011a067377dadc2f00d1fafe8088 to your computer and use it in GitHub Desktop.
Save kilasuit/4fed011a067377dadc2f00d1fafe8088 to your computer and use it in GitHub Desktop.
Example Question in Profile
function Request-YesOrNo {
[CmdletBinding()]
param
(
[Parameter(Mandatory=$false, Position=1)]
[string]$title="Confirm",
[Parameter(Mandatory=$true, Position=2)]
[string]$message="Are you sure?"
)
$choiceYes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", "Answer Yes."
$choiceNo = New-Object System.Management.Automation.Host.ChoiceDescription "&No", "Answer No."
$options = [System.Management.Automation.Host.ChoiceDescription[]]($choiceYes, $choiceNo)
try {
$result = $host.ui.PromptForChoice($title, $message, $options, 1)
}
catch [Management.Automation.Host.PromptingException] {
$result = $choiceNo
}
switch ($result) {
0 { $true }
1 { $false }
}
}
Import-Module AdditionalGitThings
$CheckGit = Request-YesOrNo -message 'Want to Check GitHub Status?'
If ($CheckGit -eq $true) { Check-GithubRepoStatus }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment