[英]Display PowerShell mandatory parameter options?
有沒有一種方法可以讓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-Object -ExpandProperty ResourceGroupName)})]
[String]$ResourceGroup
)
ValidateScript將檢查它是否是Azure中的資源組之一,但是我的問題是如何顯示資源組列表,以便運行腳本的人知道他們可以為參數輸入哪些可能的選項? 我可以使用Write-Host或Param塊中的東西嗎?
像這樣的東西將很好地顯示在它們輸入parametera值的行上(但不是靜態選項,我希望腳本查詢azure並顯示用戶可以選擇的資源組列表):
Please choose one of the following resource Groups: RG1 RG2 RG3 RG4
謝謝。
正如PetSerAI提到的,答案是使用制表符補全。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.