Invoke-Command无法找到路径,但文件仍然存在

时间:2017-08-02 15:31:07

标签: windows powershell winrm invoke-command

我是Windows脚本的新手,在尝试执行位于远程节点上的Powershell脚本时出现问题。

这是一个超级简单的HelloWorld脚本。

我正在设置会话并发出远程调用命令,如::

$session = New-PSSession -ComputerName DH2VCAUSPTCTX01.XXX.XXX.com -Credential XXX\XXX

Invoke-Command -Session $session -FilePath C:\Users\Public\EOD_CWx_Scripts\hello_world_PS.ps1

我一直收到这个错误::

Invoke-Command : Cannot find path 'C:\Users\Public\EOD_CWx_Scripts\hello_world_PS.ps1' because it does not exist. At line:1 char:1 + Invoke-Command -Session $session -FilePath C:\Users\Public\EOD_CWx_Sc ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\Users\Public...lo_world_PS.ps1:String) [Invoke-Command], ItemNotFoundException + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.InvokeCommandCommand

这是Remote节点的屏幕截图,显示文件确实存在:: enter image description here

这是我试图在远程节点上调用Powershell脚本的屏幕截图:: enter image description here

就像我说的,我是Windows脚本的新手。

远程调用Powershell脚本时,我是否遗漏了一些东西?

作为参考,我一直在使用此资源尝试找出如何执行此操作:: https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.core/invoke-command

0 个答案:

没有答案
相关问题