是否显示PowerShell强制参数选项?
有没有办法让PowerShell显示参数可能的选项?我有以下参数,需要选择Azure中的一个资源组是否显示PowerShell强制参数选项?,powershell,azure,Powershell,Azure,有没有办法让PowerShell显示参数可能的选项?我有以下参数,需要选择Azure中的一个资源组 [CmdletBinding()] Param( [Parameter(Mandatory = $true, HelpMessage = "Enter the name of the resource group you would like to use.")] [ValidateScript( {$_ -in (Get-AzureRMResourceGroup | Select
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true, HelpMessage = "Enter the name of the resource group you would like to use.")]
[ValidateScript( {$_ -in (Get-AzureRMResourceGroup | Select-Object -ExpandProperty ResourceGroupName)})]
[String]$ResourceGroup
)
ValidateScript将检查它是否是Azure中的资源组之一,但我的问题是如何显示资源组列表,以便运行脚本的人员知道他们可以为参数输入哪些可能的选项?我可以在Param块中使用Write Host或其他东西吗
在上面输入参数值的行上显示这样的内容会很好(但不是静态选项我希望脚本查询azure并显示用户可以选择的资源组列表):
谢谢。正如PetSerAI提到的,答案是使用制表符完成。您好,谢谢您的建议,但这不是我想要的。我希望脚本查询azure并显示可能选项的列表。我也不希望在他们犯了错误后显示它,但要让他们阅读上面需要输入数据的地方。然后实现参数完成器。有趣的。。。让我用谷歌搜索一下;)相关的:
Please choose one of the following resource Groups: RG1 RG2 RG3 RG4