I need to append a content of one file to another on remote machine running WinServer 2012 r2 from macOS. I have a bash script for this with these two lines
command="\"& {Get-Content -Path $readfile | Add-Content -Path $keyfile}\""
ssh -t user@server "powershell -Command $command"
and that doesn't work.
But if I write in my script this
echo "powershell -Command $command"
and then manually connect to server via SSH from my Terminal app and paste there the output from the previous command, it works well. What am I missing?
My SSH connection is maintained with keys, so I don't need to enter passwords on connecting.