function Backup-Create () { Param( [Parameter(Mandatory=$True)] [string] $source, [Parameter(Mandatory=$True)] [string] $dest, [Parameter(Mandatory=$false)] [string] $name, [Parameter(Mandatory=$false)] [object] $options ) $copy_opt = "--stats=0 --log-level INFO --log-format `"shorfile`" " Set-Message "Sync files from $source to $dest" if ( -not (Test-Path "$global:bin_path\rclone.exe") ) { Throw "Rclone executable not found" } $copy_opt = -join($copy_opt, $(ConvertTo-CmdlineOptions $options)) $command = -join($global:bin_path, "\rclone.exe", " sync", " `"$source`"", " `"$dest`"", " $copy_opt", " 2>&1") Set-Message "$command" Invoke-Expression $command -ErrorAction Ignore | % { if ($_ -ne ""){ $type, $mdg = ($_ -split ':')[0] $msg = -join ($_ -split ':')[1..2] switch ( $type.trim() ){ "INFO" { Set-Message $msg.trim() } "WARN" { Set-Warning $msg.trim() } "ERROR" { Set-Error $msg.trim() } } } } } Export-ModuleMember -Function Backup-Create