我正在尝试编写一个PowerShell cmdlet,它接受单个参数的多个输入。
例如,我可以轻松地完成以下操作:
Get-CountryList -Group "a" -Category "x"但我想做这样的事:
Get-CountryList -Groups "a b c d" -Category "x"(或)
Get-CountryList -Groups "a,b,c,d" -Category "x"我找遍了,但我找不到该怎么做。
我该怎么做呢?
发布于 2016-01-20 02:50:02
您要传递一个字符串作为参数,但是您应该传递一个字符串数组:
Get-CountryList -Groups "a" -Category "x"
Get-CountryList -Groups "a","b","c","d" -Category "x"如果您想要的话,也可以在函数中配置它:
Function Get-CountryList {
Param (
[String[]]$Groups,
[String]$Category
)
...
}https://stackoverflow.com/questions/34890490
复制相似问题