简体   繁体   English

无法运行位于远程 Azure VM D 中的远程 powershell 脚本:使用 Invoke-Command 的驱动器

[英]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.

相关问题 如何在powershell中使用invoke-command,在远程机器上运行脚本 - How to use invoke-command in powershell, to run a script on remote machine Invoke-command 不在 powershell 远程 session 中使用 cscript 运行 vbs 脚本 - Invoke-command does not run vbs script using cscript in powershell remote session PowerShell通过调用命令将本地参数传递给远程脚本 - PowerShell Passing Local Parameters to a Remote Script via Invoke-Command 使用Powershell使用Invoke-Command远程安装Python失败 - Remote Installation of Python using Powershell fails using Invoke-Command 使用Powershell Invoke-Command进行远程执行的OutOfMemory异常 - OutOfMemory Exception on remote execution using Powershell Invoke-Command 无法使用Powershell invoke-command从远程计算机获取必需的信息 - Unable to get required information from remote machines using powershell invoke-command 使用Invoke-Command在本地计算机上将脚本运行到远程 - Running a script off local machine to remote using Invoke-Command 如果使用调用命令,本地脚本 output 将保存在远程服务器上 - Local script output is saved on remote server if using invoke-command 使用“ Invoke-Command”在远程计算机上运行本地文件 - Using “Invoke-Command” to run a local file on a remote machine 以管理员身份在远程计算机上运行 Invoke-Command - Run Invoke-Command in remote computer as administrator
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM