February 2019
Intermediate to advanced
626 pages
15h 51m
English
ValidateNotNull may be used with parameters that are not flagged as mandatory. It is applicable where an object type is capable of accepting null input. Such types include object, CimInstance, and array types. The following is the simplest example of ValidateNotNull:
function Test-ValidateNotNull { [CmdletBinding()] param ( [ValidateNotNull()] $Parameter1 )}
As Parameter1 is, by default, set to the Object type, it would ordinarily accept a null value. When applied to an array, it disallows null values but retains the ability to pass an empty array into a function, for example:
function Test-ValidateNotNull { [CmdletBinding()] param ( [ValidateNotNull()] [String[]]$Parameter1 )}
If a null value is explicitly passed, ...
Read now
Unlock full access