Using MongoDB via PowerShell v4.0

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of CHARALABOS CHARALABOS 1 year, 5 months ago.

  • Author
  • #24926
    Profile photo of CHARALABOS

    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][/url]
    2. [url][/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!

  • #24927
    Profile photo of Matt McNabb
    Matt McNabb

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

    Here's another mention:

  • #24938
    Profile photo of CHARALABOS

    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:

    $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!!

You must be logged in to reply to this topic.