title: How to connect MongoDB with PowerShell?
body: <p>I already tried with the following code:</p>
  
  <pre class="lang-cs prettyprint-override"><code>$mongoDbDriverPath = '
   C:\Mongodb\net45\'
  $mongoServer = 'localhost:27017'
  
  Add-Type -Path "$($mongoDbDriverPath)MongoDB.Bson.dll"
  Add-Type -Path "$($mongoDbDriverPath)MongoDB.Driver.dll"
  $databaseName = "test"
  $collectionName = "sample"
  $client = New-Object -TypeName MongoDB.Driver.MongoClient -ArgumentList "mongodb://localhost:27017"
  $server = $client.GetServer()
  $database = $server.GetDatabase($databaseName)
  $collection = $database.GetCollection($collectionName)
  Write-Host $server,$database,$collection
  $query = [MongoDB.Driver.Builders.Query]::EQ("Name", "sample")
  
  $results = $collection.Find($query)
  $results
  </code></pre>
  
  <p>but it shows some errors:</p>
  
  <blockquote>
    <p>New-Object : Exception calling ".ctor" with "1" argument(s): "Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation,Version=4.0.0.0,`Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified."<br>
    At D:\Users\xxxxxx\Desktop\Mongodb With Powershell\task1.ps1:8 char:11</p>
  </blockquote>
  
  <p>How do I overcome this error?</p>