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

标签 powershell

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

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

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

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

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

最佳答案

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

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

http://showui.codeplex.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

关于具有多个输入字段的 Powershell 输入框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37555109/

相关文章:

mysql - 无法通过 Windows PowerShell 连接到 MySQL

sql - 构建批量插入语句powershell to sql

azure - BringOwnFeatureNotEnabled 错误代码在 Azure 中意味着什么

powershell - 用于获取所有虚拟机的正常运行时间的 Azure powershell 命令

powershell - 在Powershell中通过IP(不是主机名)重命名计算机

api - Azure Advisor API 可能的限制和筛选问题

sql - 如何使用 Powershell 检查 SQL Server 版本?

sql-server - 无法获取 ManagedComputer 的 smo 对象

Python argparse 无法正确处理 Windows 中的路径

excel - Powershell 与打开的 Excel 交互