2016-01-20 141 views
0

我想寫一個powershell cmdlet接受單個參數的多個輸入。PowerShell Cmdlet

例如,我可以做以下容易: 獲取-CountryList - 組 「一」 - 類別 「X」

但我想要做這樣的事情: GET-CountryList -groups 「ABCD」 -Category「x」 (or) Get-CountryList -Groups「a,b,c,d」-Category「x」

我搜索了但找不到如何做到這一點。

有人可以請幫忙。 -Thanks

回答

2

你傳入一個字符串作爲參數,但你應該傳遞一個字符串數組

Get-CountryList -Groups "a" -Category "x" 
Get-CountryList -Groups "a","b","c","d" -Category "x" 

您可以在函數內部配置此,如果你想還有:

Function Get-CountryList { 
    Param (
     [String[]]$Groups, 
     [String]$Category 
    ) 
    ... 
} 
+0

工作得很好。謝謝。 – Sudheer