I'm logging this for Roman Kuzmin because he cannot access the Connect site right now. This comes from an issue he raised on the PowerShell newsgroup. It is not possible, at least as far as he or I can tell, to pass null as null into a .NET method that has a string parameter. For example, take a look at this class definition (provided by Roman):
public static class Class1
public static string Foo(string value)
if (value == null)
return "Special processing of null.";
return "'" + value + "' has been processed.";
If you build this and then try accessing it from PowerShell, how can you call Foo such that the "Special processing of null." section is used? If you call Foo with $null, an empty string is passed into the method. If you call it with a variable assigned to null, you get the same result. Anything else we have tried results in the same thing.
This isn't a problem when you own the source for the .NET class, but if you are using anything that you don't own the source to you can't trigger any special handling that would occur if null was passed in.
Is this a defect? It certainly seems like one. If you have a workaround or undocumented way that this can be done, it would be really appreciated.