I already tried with the following 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
but it shows some errors:
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."
At D:\Users\xxxxxx\Desktop\Mongodb With Powershell\task1.ps1:8 char:11
How do I overcome this error?