Video of the week

This is a must-watch video about one of us trying to reach the stars :-)

Well done #HRejterzy

How to reIndex a mongoDB collection using PowerShell

I wanted to find a way to automatically rebuild the index of a particular mongoDB collection, but this time with kind of different approach. As I've been getting familiar with PowerShell for some time now, I wanted to write a script and resign from writing anything with the help of pure .NET technology and Visual Studio (I'm aware that PowerShell is based on .NET but it's not the same as writing code using the most popular IDE by Microsoft). To make a long story short if you want to use PowerShell cmdlet(s) to work with your mongoDB instance visit the following website - https://www.powershellgallery.com/packages/Mdbc/5.1.5 - and read more on how to work with Mdbc module written by Roman Kuzmin.

Install the module and list all the cmdlet(s) included in the package:

mdbc

If you want to read more about each of these cmdlet(s) use the following command pattern: Get-Help <Cmdlet> -Full (or use my second favorite pattern: Help <Cmdlet> -Examples)

My short script looks as follows:

phonebook

The reason why I put the database name in a red circle is to indicate, that this is the database you authenticate your mongoDB user against. If another database is used to authenticate a user then you should attach it at the end of that connection string - simply replace phonebook with the right one.

Another thing is to check if the script actually works:

powershell

And the last thing was to add it to Windows Scheduler so it could run daily:

scheduler