![](/img/trans.png)
[英]How to use invoke-command in powershell, to run a script on remote machine
[英]Unable to run remote powershell script which is located in remote Azure VM D: drive using Invoke-Command
我的猜测是错误可能出在您的GetRemoteAzureVMHstName.ps1
脚本中。
确保它实际上在打印一些东西。
我的脚本现在工作正常。
在Invoke-Command
中,对于-Command
我删除了脚本文件路径的单引号并且它起作用了。
Invoke-Command
应如下所示
Invoke-Command -Session $s -Command { D:\User1\GetRemoteAzureVMHstName.ps1 }
而不是下面
Invoke-Command -Session $s -Command { 'D:\User1\GetRemoteAzureVMHstName.ps1' }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.