In PowerShell one can define C# code and execute it. Passing in $null into the following simplest function shows that not null gets passed into the function
Evidently the solution is "don't pass $null
to a [String]
parameter if you want a $null
[String]
". There is a special [NullString]
class that should be used instead.
PS > [foo]::fooo($Null)
Not Null. Is ''
PS > [foo]::fooo([NullString]::Value)
PS >
I can't find any mentions of the need to use [NullString]
in the PowerShell documentation, nor does the source code for the NullString class include any comments explaining its purpose.