To execute commands against a MongoDb database as a scheduled task is simple, and requires two files.

Say, for example, I want to update the Priority property of all documents in a collection once a day. Assuming your working folder is C:\MongoDb\Temp, create a myscript.js file with the following commands:

db.getCollection('Workflows').update( {}, { $set : { "Priority" : 1 } }, true, true);

Then, create a run.bat file, which will execute the above script file:

@echo off
"C:\MongoDb\v4\bin\mongo.exe" -u useraccount -p yourpassword --authenticationDatabase admin YourDatabase < C:\MongoDb\Temp\myscript.js

You can then set up your scheduled task, making sure to set the action properties as follows:

MongoDb Scheduled Task Action

Note that the starting folder must be set to the location of your script.