Execute powershell command remotely to run in the background

Viewed 309

I'm connecting to windows machine using ssh and trying to execute command to run in the background. Running the following command from the terminal after ssh established works:

start PowerShell.exe -ExecutionPolicy Unrestricted Invoke-Command -ScriptBlock{"cd C:\Users\myuser\AppData\Roaming\npm\node_modules\myserver\; npm start > log.log 2>&1"}

But what I really need is to run the following command and it doesn't work:

ssh myuser@machine_ip "start PowerShell.exe -ExecutionPolicy Unrestricted Invoke-Command -ScriptBlock{\"cd C:\Users\myuser\AppData\Roaming\npm\node_modules\myserver\; npm start > log.log 2>&1\"}"

Running the second command without 'start' works but it 'holds' the terminal. And basically it's not a must to work with powershell if someone can tell how to execute the below command and make it run in the background: cd C:\Users\myuser\AppData\Roaming\npm\node_modules\myserver\; npm start > log.log 2>&1

thanks

1 Answers
Related