3

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?

1 Answer 1

4

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"'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .