Archive | Move file RSS for this section

Stop/Restart/Pause OneDrive for business

I had an issue with OneDrive for business, which I need to use to be able to sync a SharePoint folder to my local machine.

On this machine I like to do some auto cleanup with my MoveOldFiles script (a script that moves all files in certain folders to sub folders in the format yyyy\MM, and after doing so, it uses 7za.exe to zip the files, once complete and zipped successfully the source files are being deleted). But when doing so, OneDrive kept syncing the changes and while zipping and deleting, sometimes sync errors might occur. I wanted this to be more robust and stable and not have OneDrive crash or starting to consume a lot of memory.

On trying to find how to pause OneDrive trough a script, I couldn’t find any solutions, but some solutions pointed to a SkyDrive /shutdown option. OneDrive for business uses groove nowadays instead of SkyDrive, but they kept this argument switch alive.

So, all I had to do was to add 2 lines of code to my script.
One line to shut down the OneDrive service (the installation can usually be found here: C:\Program Files\Microsoft Office 15\root\office15):

Groove.exe /shutdown

And one to restart is


And that was all there is to it, this way OneDrive is closed during my automatic cleanup sessions and will be restarted after all is done and then it starts syncing all changes.


Move-item and files with [ and ] in its filename

I was researching a bug in a script of mine, where most files would be moved, exept some. The behaviour seemed irregular, until I noticed that the files not being moved had 1 thing in common. They all had brackets [ ] in their file name. It appears that if you use Move-item -Path <filename> -Destination <destination path> it won’t work on files with those brackets in its name. To make Move-item move these files too, use the switch LiteralPath instead of Path:

Move-Item -LiteralPath <filename> -Destination <destination path>