具有多个输入字段的Powershell输入框

Pet*_*lka 3 powershell

我发现这段代码可以为 powershell 创建简单的输入框:

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

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

$text = [Microsoft.VisualBasic.Interaction]::InputBox($msg, $title)
Run Code Online (Sandbox Code Playgroud)

有谁知道如何添加更多输入字段?

Ant*_*ger 6

WPF、XAML、.NET 和 ShowUI 都是您可用的选项。

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

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

此外,您还可以使用 Visual Studio 社区版(免费)或付费工具,例如https://poshgui.com/

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
Run Code Online (Sandbox Code Playgroud)

  • 试试这个 `$input1 = $result.Demographics` (2认同)