使用修改选项预填充powershell参数
我有这样一个powershell脚本:使用修改选项预填充powershell参数,powershell,powershell-2.0,powershell-ise,powershell-4.0,Powershell,Powershell 2.0,Powershell Ise,Powershell 4.0,我有这样一个powershell脚本: [CmdletBinding()] Param( [Parameter(Mandatory=$True)] [string]$age="8" ) process { Write-Host "Your age is $age" } 如何修改此脚本,使shell向我询问年龄并在其旁边加上8,但允许用户在按enter键之前更改值?不确定这是否是您要求的,但我会这样做 [CmdletBinding()] Param(
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
[string]$age="8"
)
process
{
Write-Host "Your age is $age"
}
如何修改此脚本,使shell向我询问年龄并在其旁边加上8,但允许用户在按enter键之前更改值?不确定这是否是您要求的,但我会这样做
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
[string]$age="8"
)
process
{
$yourage = "8" + $age
Write-Host "Your age is $yourage"
}
如果年龄=29岁
返回:你的年龄是829我明白你的意思。但我希望powershell将age提示符显示为age:5,然后允许我替换它或在提示符本身上使用它。无法使其工作…听起来您需要Read InputBoxDialog Read InputBoxDialog-消息输入您的年龄-WindowTitle示例-DefaultText 5Hmm…我认为我不需要windows对话框,但这是唯一的解决方案还是另一种方法?我是否应该以其他方式实现目标?这是我能想到的实现您所需的最佳方式,除非您可以对读主机和写主机执行相同的操作