I have a Windows machine with openssh-server running and I can execute commands through it. For example...

This works:

ssh vc-mgmt powershell -nologo -Command "get-vm"

This does not work:

ssh vc-mgmt powershell -nologo -Command "get-vm | get-snapshot"

Returns error:

'get-snapshot' is not recognized as an internal or external command, operable program or batch file.

If I open Powershell manually and run get-vm | get-snapshot it works as expected.

My Question: How can I get the 2nd example to work?


I figured it out the | was being interpreted by ssh. I just needed to add single quotes to the command SSH will execute. The following works.

ssh vc-mgmt 'powershell -nologo -Command "get-vm | get-snapshot"'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.