I would like to propose the idea of a PowerShell module for Rclone. That would combine the power of Powershell with Rclone's robust copy/sync capability.
can you please provide some detailed examples?
There can be a ton of use-cases. Right now, there is no 'connectivity' between PS and rclone; they run as independent processes. On the other hand, Powershell modules have the ability to interact directly with the Powershell process. This comes handy when you want to utilize the output of a command further down in your PS script. To give you an example, just a random one, let's say I want to rename files on a remote. The files have date in their name (e.g. Whatsapp images) and I want the new name to have that date in a different format. This would be so much easier to loop through in PS if the "rclone lsf remote:path" output were a structured PS object. I know this particular example-usecase can probably be done even without a module, but that's all I could think of while travelling in a train at this moment.
In general, what rclone offers is such a good contender for automation. Having an integration with a scripting language would make it so much more powerful.
I agree, it could be nice to have something like that. However, I personally don't see it adding enough to warrant the maintenance cost.
For simple use cases like the one you mention, I think rclone lsjson and ConvertFrom-Json would get you a long way. And then you have Remote Control / API, with Json-based API, which is quite flexible. In addition, you also have rclone completion powershell, and --use-json-log.
If one were to invest in a more "native" PowerShell integration, I would first look into Crescendo, which is a framework for wrapping command-line tools to get "the syntax, readability, and object-based output that cmdlets provide".
I think that's what the json output is for. I'm currently writing a backup manager for rclone and restic entirely in Powershell and haven't had any issues working with rclone. It's actually easier.
i wrote a backup manager:
- server stores the credentials. agents login to server using 2FA.
- agents doing the actual backups on clients' machines.
- as most of the endpoints are S3 and sftp, rclone config file is optional.
at first i started to use powershell but i soon realized it was not a good choice.
so i used python.
- linux compatibility.
- powershell is a second class citizen on linux.
- have to install and maintain powershell on all linux serves and clients.
- portable app.
- rclone and restic are portable apps, no dependencies. just copy the executable to machine and run it.
- with python, that can be achieved using pyinstaller.