Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell input box with multiple inputfields

Tags:

powershell

I've found this code to create simple input box for powershell:

[void][Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')

$title = 'Demographics'
$msg   = 'Enter your demographics:'

$text = [Microsoft.VisualBasic.Interaction]::InputBox($msg, $title)

Does anyone know how to add more input fields?

like image 800
Peter Pavelka Avatar asked May 09 '26 12:05

Peter Pavelka


1 Answers

WPF, XAML, .NET, and ShowUI are all options available to you.

https://learn-powershell.net/2012/09/13/powershell-and-wpf-introduction-and-building-your-first-window/

http://www.show-ui.com/

also, you can use visual studio community edition (free) or a paid tool such as https://poshgui.com/

alternatively, here is an example using the Show-Command cmdlet

function askforinfo {
    param (
        [string]$Demographics,
        [validateset(1, 2, 3)]
        [string]$otherstuff
    )
    [pscustomobject]@{
        Demographics = $Demographics
        OtherStuff = $otherstuff
    }
}

$result = Invoke-Expression (Show-Command askforinfo -PassThru)

$result
like image 73
Anthony Stringer Avatar answered May 12 '26 03:05

Anthony Stringer