【问题标题】:How do i make powershell custom input boxes?如何制作powershell自定义输入框?
【发布时间】:2016-09-27 15:50:49
【问题描述】:

所以我有这个 powershell...

pushd "C:\PSF\Move to V6\DTT Files"
$configFiles = Get-ChildItem . *.dtt -rec
foreach ($file in $configFiles)
{
(Get-Content $file.PSPath) |
Foreach-Object { $_ -replace "OLD", "NEW" } |
Set-Content $file.PSPath
(Get-Content $file.PSPath) |
Foreach-Object { $_ -replace "OLD2", "NEW2" } |
Set-Content $file.PSPath
(Get-Content $file.PSPath) |
Foreach-Object { $_ -replace "OLD3", "NEW3" } |
Set-Content $file.PSPath
}

我希望做的是让它弹出几个框,询问你想要什么: 具体来说是New、New2和New3。

我对 powershell 很陌生,所以在做类似的事情时我一无所知。 (或者即使你可以)

如果不可能,我会接受关于我可以做的其他事情的建议。

【问题讨论】:

标签: powershell textbox inputbox


【解决方案1】:

如果您使用的是 PowerShell v3+,那么我喜欢为此使用 Out-GridView

$choices = @('NEW', 'NEW2', 'NEW3')

$selection = $choices | Out-GridView -Title 'Select Replacement' -OutputMode Single

它简单、有效、直观且内置。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-09
    • 1970-01-01
    • 2011-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多