I have a Windows Client machine and I would like to invoke a powershell script on that client from my local machine i.e. Mac. I have ssh on Windows via freesshd. Also, i need to provide password via script hence I ended up using sshpass. From my Mac Terminal, while the command:
sshpass -v -p xxx ssh administrator@x.x.x.x "powershell.exe dir"
runs perfectly and returns the content of whatever directory the shell lands in, i am unable the get the same result from inside a shell script.
The simple script is as below:
cmd='sshpass -v -p xxx ssh administrator@x.x.x.x "powershell.exe dir"'
echo `$cmd`
What I get is:
Unable to execute command or shell on remote system: Failed to Execute process.
I have tried various permutations of " and ' to get the correct command string but to no avail. What is wrong here?