PowerShell not compatible with MongoDB C# Driver’s Methods?


Problem with latest MongoDB Driver caused by the C# Generics:

I could probably use other GetCollection methods without the generics, but I do not know how exactly.

The answer posted further down points out some good information but unfortunately the provided code was the same than I already tried and it is not working.

Here is what I would like to do:

I want to work with PowerShell to create a few documents.
The issue I am facing now seems that “GetCollection” does not work properly. I think it has to do with the lack of support for generics in Powershell. Anyway I found some CmdLets to run generic methods. But I think this will make the code too complicated. Is there a way to get around this issue?

I saw that there are other GetCollection methods which are not based on C# Generics, but I do not understand yet how to use them in PowerShell.

Powershell Exception: Cannot find an overload for "GetCollection" and the argument count: "1"

The code listed above is copied (and slightly changed) from an earlier SO question: Powershell Mongodb Authentication

Any suggestion how this can be done? I assume that the code listed in the SO is based on an earlier driver version. I think that is why it is not working any more.

Full Exeption on PowerShell console:


I hope this can still be of some help, this worked for me with the latest C# Driver and the current MongoDB RC-4.


PowerShell not compatible with MongoDB C# Driver’s Methods? by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply