I'm struggeling with this for a day now. Basically I want to backup a MySQL database on our webspace with a powershell script which runs daily on my windows computer.
When I use Putty and enter the following command, a backup file is created:
mysqldump XXXX --add-drop-table -u XXXX -p******* > backup/backup.sql
But when I run it from powershell, it will not create the backup file, even when I invoke the exact same command:
$sshsession = New-SSHSession -ComputerName $sshserver -Credential $Creds -Force -Verbose
[string]$backupcmd = "mysqldump XXXX --add-drop-table -u XXXX -p******* > backup/backup.sql"
Write-Output $backupcmd
$backupdb = Invoke-SSHCommand -SSHSession $sshsession -Command "$backupcmd"
It seems like Posh-SSH has problems with the ">" operator, maybe it does not have enough time to execute, I don't know. Also tried things like Timeout on Invoke-SSHCommand, but nothing did work yet.
I can't do stuff like crons on the remote server, it's just a webspace with limited functionalities. Also starting a bash-script does not work, I have no rights to execute scripts on the remote server.