无法使用Invoke-Command运行位于远程Azure VM D:驱动器中的远程Powershell脚本 [英] Unable to run remote powershell script which is located in remote Azure VM D: drive using Invoke-Command
问题描述
我尝试在本地计算机中使用以下脚本运行位于remote azure vm
中的remote powershell script
.
I tried with below script in local machine to run remote powershell script
which is located in remote azure vm
.
我可以通过powershell pssession
连接到azure remote vm
,但是Invoke-Command
不返回任何内容.无法运行remote powershell script
.
I'm able to connect to azure remote vm
through powershell pssession
, but Invoke-Command
is not returning anything. Unable to run remote powershell script
.
我也尝试如下
但是-FilePath
试图查看本地计算机D:
驱动器,而不是远程天蓝色的vm D:
驱动器.
But -FilePath
trying to look into local machine D:
drive instead of remote azure vm D:
drive.
如何运行位于远程azure vm D:
驱动器中的远程azure vm powershell脚本
How to run remote azure vm powershell script which is located in remote azure vm D:
drive
推荐答案
我的脚本现在可以正常工作了.
My script is working fine now.
在Invoke-Command
中,对于-Command
,我删除了脚本文件路径的单引号,并且有效.
In Invoke-Command
, for -Command
I removed single quotes for script file path and it worked.
Invoke-Command
应该如下所示
Invoke-Command -Session $s -Command { D:\User1\GetRemoteAzureVMHstName.ps1 }
而不是下面的
Invoke-Command -Session $s -Command { 'D:\User1\GetRemoteAzureVMHstName.ps1' }
这篇关于无法使用Invoke-Command运行位于远程Azure VM D:驱动器中的远程Powershell脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!