I'm not a coder but trying to help my development team by taking on simple tasks myself, one of which is to set up a Windows scheduled task to export components of our mongodb through Powershell. With help from http://docs.mongodb.org/manual/administration/import-export/ and some trial and error (as well as a bit of troubleshooting help from dev friends), I've been able to write some Powershell command lines that successfully export the relevant Mongodb collections when manually executed within Powershell:
cd c:\mongobinlocation
.\mongoexport --db db --collection collection1 --jsonArray --out "\\server\archivelocation\collection1.json"
.\mongoexport --db db --collection collection2 --jsonArray --out "\\server\archivelocation\collection2.json"
.\mongoexport --db db --collection collection3 --jsonArray --out "\\server\archivelocation\collection3.json"
However, I then set upon trying to set up a scheduled task to run the script in Powershell (using instructions here: http://www.ilovepowershell.com/how-to-run-powershell-script-as-scheduled-task/) and realized that the Powershell command lines that I have set up do not equate to a Powershell script that can be run in a scheduled task. I'm looking for a basic template example that I could modify to insert my command lines above and I've had no luck- everything I see looks drastically different than my little ol' command lines. Is there any way to wrap the above commands into something basic or do I have to start from scratch and learn how to write a Powershell script?
Thanks for any and all help, and I appreciate your time!
.bat
file - there don't appear to be any PowerShell commands in there. You can just save your file as a.bat
, then create a scheduled task to run it - no template required! – Simon MᶜKenzie Mar 21 '13 at 5:14