Author Posts

May 4, 2015 at 6:15 am

Hello community,
I've recently tried to use a noSQL document database called MongoDB in order to store eventlog entry data.
I followed instructions from here:
1. [url]https://danielweberonline.wordpress.com/2012/01/30/query-and-update-data-on-mongodb-using-powershell/[/url]
2. [url]http://kowalski.ms/2012/07/04/working-with-mongodb-and-powershell/#comment-21942[/url]

I'm using WinServ2012 Powershell v4 but I deal with this console response:
_____________________________________________________________________________________________
Add-Type : Could not load file or assembly 'file:///C:\mongodb\bin\MongoDB.Bson.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
At line:1 char:1
+ Add-Type -Path "c:\mongodb\bin\MongoDB.Bson.dll"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-Type], FileLoadException
+ FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.AddTypeCommand
_____________________________________________________________________________________________

Is there any recommendation that would help me go further with this and store my data with this way?
Thank You very much!
CV

May 4, 2015 at 6:44 am

According to this blog from 2012, you need a MongoDB C# driver to make this work:

http://fatbeards.blogspot.com/2012/02/powershell-and-mongodb.html

Here's another mention:

PowerShell and MongoDB

May 4, 2015 at 9:35 am

Thank you very very much for the reply MR Matt McNabb!!!! This helped me much!!
While I was trying to deal with mongodb, I didn't installed the exe file from mongoDB official site.
Contrary, I installed files manually and I created a service and a process for mongodb.
This was a fault I think because the installation didn't fully complete.
I'll try to install official .net driver from mongodb .exe tomorrow and I will reply here for what will happen.

In addition i found here:
[url]https://gist.github.com/Gab-km/25b00d110e4fea0306a4[/url]

[System.Reflection.Assembly]::LoadFile('/path/to/MongoDB.Driver.dll')
[System.Reflection.Assembly]::LoadFile('/path/to/MongoDB.Bson.dll')
$client = New-Object MongoDB.Driver.MongoClient("mongodb://hostname")

which shows that there's a new way to "import" the dlls within powershell.

Whatever will happen I 'll reply here, if I will find a way to implement my database connection within Powershell!

thank you again I am looking forward for every one else knows something more!!