Created
March 9, 2014 06:49
-
-
Save hobelinm/9443818 to your computer and use it in GitHub Desktop.
Simple dialog box in PowerShell
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
# Load libraries | |
[void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | |
# Selection box | |
$input = [Microsoft.VisualBasic.Interaction]::MsgBox("Do you agree?", 'YesNoCancel,Question', "Respond Please") | |
# Process input as desired | |
switch($input) | |
{ | |
'Yes' | |
{ | |
Write-Host "Good Choice" -ForegroundColor Green | |
} | |
'No' | |
{ | |
Write-Host "You've selected No" -ForegroundColor Red | |
} | |
'Cancel' | |
{ | |
Write-Warning "Exiting this script..." | |
} | |
} | |
# General input box | |
$info = [Microsoft.VisualBasic.Interaction]::InputBox("Enter Some Data", ` | |
"Title box", "Initial Default Value") | |
# Shows what the user entered | |
Write-Host $info -ForegroundColor Cyan |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment