remote-execution

Expand string Variable stored via Single Quote in Powershell

一曲冷凌霜 提交于 2019-11-28 14:15:16
I have a scenario where I need to construct a powershell path as $RemotePath = '$($env:USERPROFILE)\Desktop\Shell.lnk' . This variable gets passed to a remote machine where it needs to be executed. The remote machine receives this as a string variable. How do I expand the string to evaluate $env:USERPROFILE ? Ansgar Wiechers Expand the string on the remote side: $ExecutionContext.InvokeCommand.ExpandString($RemotePath) By using a double quotes. PowerShell won't expand variables inside single-quoted strings. 来源: https://stackoverflow.com/questions/27226606/expand-string-variable-stored-via

How to use SSH to run a shell script on a remote machine?

我们两清 提交于 2019-11-25 22:21:44
问题 I have to run a shell script (windows/Linux) on a remote machine. I have SSH configured on both machine A and B. My script is on machine A which will run some of my code on a remote machine, machine B. The local and remote computers can be either Windows or Unix based system. Is there a way to run do this using plink/ssh? 回答1: If Machine A is a Windows box, you can use Plink (part of PuTTY) with the -m parameter, and it will execute the local script on the remote server. plink root@MachineB