Powershell Invoke-Command with-FilePath 给出 ItemNotFoundException [英] Powershell Invoke-Command with-FilePath Gives ItemNotFoundException
本文介绍了Powershell Invoke-Command with-FilePath 给出 ItemNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我建立了一个持久会话,然后尝试使用以下行远程执行脚本:
I establish a persistent session then attempt to execute a script remotely using the following line:
Invoke-Command -Session $Session -FilePath "FullStopBizTalkApp.ps1" -argumentlist $BizTalkMgmtDBConString, $ApplicationNameInBizTalk
如果我然后执行:$_.Exception.ToString() 我可以看到以下错误:
If I then execute: $_.Exception.ToString() I can see the following error:
System.Management.Automation.ItemNotFoundException: Cannot find path 'C:\Users\tfs_service\FullStopBizTalkApp.ps1' because it does not exist.
使用 -ScriptBlock 时,我可以从同一个客户端向同一个目标服务器调用命令,我只在使用 -FilePath 时遇到问题
I am able to invoke commands from the same client to the same target server when using -ScriptBlock, I only get the problem when using -FilePath
有什么想法吗?
推荐答案
输入脚本的路径和文件名,或者确保你的会话工作目录是脚本文件的父目录.
Enter the path and file name of the script, or make sure your session working directory is the parent directory of the script file.
这篇关于Powershell Invoke-Command with-FilePath 给出 ItemNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文