Thanks
I’ve spent some more time on this, and have it working with methods that contain optional parameters (parameters with default values). I’ve separated the worker functions out into a psm1 module and added some basic comment-based help to Invoke-GenericMethod.
I also updated the code to handle methods that contain parameters that are generic types (ie, List<T>), but am running into some problems invoking that type of method (even non-generic methods). I suspect that if I rewrite this function as a C# cmdlet, that problem will go away; it appears to be something PowerShell-related, and I may not be able to fix it. I’m getting the following exception:
Exception calling “Invoke” with “2″ argument(s): “Object of type ‘System.Management.Automation.PSObject’ cannot be converted to type ‘System.Collections.Generic.List`1[System.String]‘.”
Even though I’ve verified that the value being passed to Invoke is an object[] array containing a List<string> object. I’m not sure where PSObject is entering the picture there. Aside from that little hiccup, it seems to be working great. If you get any other errors, let me know.