The AllowEmptyCollection attribute

AllowEmptyCollection, as the name suggests, allows an empty array to be assigned to a mandatory parameter:

function Test-AllowEmptyCollection {
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[AllowEmptyCollection()]
[Object[]]$Parameter1
)
}

This will allow the command to be called with an explicitly empty array:

Test-AllowEmptyCollection -Parameter1 @()
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.39.23