Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Requirement
Our Service Desk needs a Prompt for Choice while executing PowerShell.
Solution
It's possible - but it matters how you modify it.
Trick: In this demo, we will show a pop up with Short Keys.
$Title = "Welcome"
$Info = "Just to Demo Promt for Choice"
$options = [System.Management.Automation.Host.ChoiceDescription[]] @("&Power", "&Shell", "&Quit")
[int]$defaultchoice = 2
$opt = $host.UI.PromptForChoice($Title , $Info , $Options,$defaultchoice)
switch($opt)
{
0 { Write-Host "Power" -ForegroundColor Green}
1 { Write-Host "Shell" -ForegroundColor Green}
2 {Write-Host "Good Bye!!!" -ForegroundColor Green}
}
Hotkey
&Power makes P a Hot Key.
Enjoy PowerShell.