无法使用Invoke-Command运行位于远程Azure VM D:驱动器中的远程Powershell脚本 [英] Unable to run remote powershell script which is located in remote Azure VM D: drive using Invoke-Command

查看:218
本文介绍了无法使用Invoke-Command运行位于远程Azure VM D:驱动器中的远程Powershell脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在本地计算机中使用以下脚本运行位于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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆