title: PowerShell not compatible with MongoDB C# Driver's Methods?
body: <p>Problem with latest MongoDB Driver caused by the C# Generics:</p>
  
  <pre><code>Cannot find an overload for "GetCollection" and the argument count: "1".
  </code></pre>
  
  <p>I could probably use other GetCollection methods without the generics, but I do not know how exactly.</p>
  
  <p>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.</p>
  
  <p>Here is what I would like to do:</p>
  
  <p>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?</p>
  
  <p>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.</p>
  
  <p>Powershell Exception: <code>Cannot find an overload for "GetCollection" and the argument count: "1"</code></p>
  
  <pre><code># Mongo DB driver
  Add-Type -Path 'CSharpDriver-2.0.1\MongoDB.Bson.dll'
  Add-Type -Path 'CSharpDriver-2.0.1\MongoDB.Driver.dll'
  
  # Conncetion to MongoDB
  $connectionString = "mongodb://localhost:27018"
  $db =  "TestDB"
  $collection =  "Test"
  
  
  function Get-MongoDBCollection ($connectionString, $db, $collection)
  {
     $mongoClient = New-Object MongoDB.Driver.MongoClient($connectionString)
     $mongoDatabase = $mongoClient.GetDatabase($db)
     $mongoCollection = $mongoDatabase.GetCollection($collection)
     return $mongoCollection
  }
  
  
  # Connect to MongoDB and get collection
  $mongoCollection = Get-MongoDBCollection $connectionString $db $collection
  </code></pre>
  
  <p>The code listed above is copied (and slightly changed) from an earlier SO question: <a href="https://stackoverflow.com/questions/27695670/powershell-mongodb-authentication">Powershell Mongodb Authentication</a></p>
  
  <p>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.</p>
  
  <p>Full Exeption on PowerShell console:</p>
  
  <pre><code>Cannot find an overload for "GetCollection" and the argument count: "1".
  At F:\PowerShell\CreateDB.ps1:31 char:3
  +   $mongoCollection = $mongoDatabase.GetCollection($collection)
  +   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : NotSpecified: (:) [], MethodException
      + FullyQualifiedErrorId : MethodCountCouldNotFindBest
  </code></pre>