Created
November 29, 2021 15:30
-
-
Save csev1755/885ab7f0029e495b5758dd04f05128e7 to your computer and use it in GitHub Desktop.
Let user skip certain parts of script in PowerShell
This file contains 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
function Get-Choice { | |
param ($question) | |
while ($True) { | |
$choice = Read-Host ($question + " (y/n)") | |
if ($choice.ToLower() -eq "y") {return $True} | |
elseif ($choice.ToLower() -eq "n") {break} | |
else {continue} | |
} | |
} | |
if (Get-Choice "Write test output?") { | |
Write-Output "Test" | |
} | |
# Write test output? (y/n): y | |
# Test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment