在PowerShell高级功能中解释AllowEmptyString()和AllowEmptyCollection()。
输出 -
PS C:\WINDOWS\system32> print_String cmdlet print_String at command pipeline position 1 Supply values for the following parameters: name: Writing a single string
在上面的示例中,您可以看到添加了参数之后AllowEmptyString(),程序将接受Empty字符串。同样,当您添加AllowEmptyCollection()参数时,PowerShell将接受数组的空值。
function print_String{
[cmdletbinding()]
param(
[parameter(Mandatory=$True)]
[AllowEmptyCollection()]
[string[]]$stringarray
)
Write-Output "Writing a string array"
$stringarray
}输出结果
PS C:\WINDOWS\system32> print_String cmdlet print_String at command pipeline position 1 Supply values for the following parameters: stringarray[0]: Writing a string array
热门推荐
10 医院探望朋友祝福语简短
11 毕业祝福语简短女朋友
12 春节虎年爸妈祝福语简短
13 儿童毕业祝福语 简短6
14 开工仪式横幅祝福语简短
15 孩子日常祝福语大全简短
16 清晨寄语诗句祝福语简短
17 结婚送亲认亲祝福语简短
18 虎年喝酒拜年祝福语简短