February 2019
Intermediate to advanced
626 pages
15h 51m
English
Commands such as Where-Object allow an explicit null value in the input pipeline. To allow null in an input pipeline, the [AllowNull()] attribute would be added to the InputObject parameter. There is a difference between supporting $null | Get-InputObject and implementing pipeline support originating from a command that returns nothing: AllowNull is only needed when an explicit null is in the input pipeline.
In the following example, the Get-EmptyOutput function has no body and will not return anything. This simulates a command that returns nothing because all of the output is filtered out. The Get-InputObject function can take part in a pipeline with Get-EmptyOutput without using AllowNull:
function Get-EmptyOutput { ...Read now
Unlock full access