在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
热门推荐
4 狗狗请人训练
5 训练狗狗迎宾
6 训练狗狗解放
7 抬头训练狗狗
10 训练狗狗的基本动作
11 两个月狗狗怎么训练大小便
12 教狗狗训练
13 记叙文训练狗狗
14 潮州训练狗狗
15 训练狗狗叫的方法
16 猫训练狗狗
17 狗狗训练如厕
18 狗狗来训练