Invoke Generic Methods from PowerShell

PowerShell handles .NET Generic types fairly well, but doesn't make it easy to call less common Generic methods. The Invoke-GenericMethod function allows you to call these methods with a single line of PowerShell code, without dealing with Reflection yourself.

5 Star
1,812 times
Add to favorites
E-mail Twitter Digg Facebook
  • Generic method of the MongoDb driver
    1 Posts | Last post February 21, 2018
    • Hi! I just wanted to report that this module doesn't correctly work with 'FindSync' method from the latest MongoDB driver:
      $test = Invoke-GenericMethod -InputObject $databaseHandle -MethodName 'FindSync' -GenericType MongoDB.Bson.BsonDocument -ArgumentList $query
      Invoke-GenericMethod : No matching method was found
      $test = Invoke-GenericMethod -InputObject $databaseHandle -MethodName 'FindSync' -GenericType PSOBJECT -ArgumentList $query
      Invoke-GenericMethod : No matching method was found
      (this method is overloaded with 3 and 4 parameters, that might be the reason, as other ones, such as GetCollection seem to be working fine)