February 2019
Intermediate to advanced
626 pages
15h 51m
English
In some rare cases, it may be desirable for a parameter to accept either null or a specific value type. For example, a parameter may need to accept either a date, or null.
A nullable type can be defined for the parameter:
function Test-Nullable { param ( [Nullable[DateTime]]$Date )}
The function can be called with a null value for Date:
Test-Nullable -Date $null
Without the nullable type, a type-conversion error message would be thrown.
Read now
Unlock full access