Using MongoDB via PowerShell v4.0

Welcome Forums General PowerShell Q&A Using MongoDB via PowerShell v4.0

This topic contains 2 replies, has 2 voices, and was last updated by

3 years, 8 months ago.

  • Author
  • #24926

    Points: 0
    Rank: Member

    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:

    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

    Points: 2
    Rank: Member

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

    Here's another mention:

    PowerShell and MongoDB

  • #24938

    Points: 0
    Rank: Member

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

The topic ‘Using MongoDB via PowerShell v4.0’ is closed to new replies.