[英]Unable to run remote powershell script which is located in remote Azure VM D: drive using Invoke-Command
I tried with below script in local machine to run remote powershell script
which is located in remote azure vm
.我尝试在本地机器上使用以下脚本运行
remote powershell script
,该脚本位于remote azure vm
中。
I'm able to connect to azure remote vm
through powershell pssession
, but Invoke-Command
is not returning anything.我可以通过
powershell pssession
连接到azure remote vm
虚拟机,但Invoke-Command
没有返回任何内容。 Unable to run remote powershell script
.无法运行
remote powershell script
。
I tried as below aswell我也试过如下
But -FilePath
trying to look into local machine D:
drive instead of remote azure vm D:
drive.但是
-FilePath
试图查看本地机器D:
驱动器而不是远程 azure vm D:
驱动器。
How to run remote azure vm powershell script which is located in remote azure vm D:
drive如何运行位于远程 azure vm
D:
驱动器中的远程 azure vm powershell 脚本
My guess is that the fault probably lies in your GetRemoteAzureVMHstName.ps1
script.我的猜测是错误可能出在您的
GetRemoteAzureVMHstName.ps1
脚本中。
make sure it's actually printing something.确保它实际上在打印一些东西。
My script is working fine now.我的脚本现在工作正常。
In Invoke-Command
, for -Command
I removed single quotes for script file path and it worked.在
Invoke-Command
中,对于-Command
我删除了脚本文件路径的单引号并且它起作用了。
Invoke-Command
should be as below Invoke-Command
应如下所示
Invoke-Command -Session $s -Command { D:\User1\GetRemoteAzureVMHstName.ps1 }
instead of below而不是下面
Invoke-Command -Session $s -Command { 'D:\User1\GetRemoteAzureVMHstName.ps1' }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.