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

4xrmg8kj  于 2023-05-29  发布在  Shell
关注(0)|答案(1)|浏览(251)

我找到了以下代码来为powershell创建简单的输入框:

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

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

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

有人知道如何添加更多的输入字段吗?

xesrikrc

xesrikrc1#

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 community edition(免费)或付费工具,如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

相关问题