Powershell 通过调用命令调用远程cmdlet(ffmpeg):“;。。。未被识别为名称……”;

Powershell 通过调用命令调用远程cmdlet(ffmpeg):“;。。。未被识别为名称……”;,powershell,ffmpeg,invoke-command,Powershell,Ffmpeg,Invoke Command,我正在尝试通过Powershell在远程转码服务器上调用ffmpeg: $session = new-pssession -computername transcodingserver Invoke-Command -session $session -scriptblock { powershell ffmpeg } ffmpeg已正确安装在远程服务器上,并且可以在那里运行,但远程调用会导致错误: ffmpeg : The term 'ffmpeg' is not recognized as

我正在尝试通过Powershell在远程转码服务器上调用ffmpeg:

$session = new-pssession -computername transcodingserver
Invoke-Command -session $session -scriptblock { powershell ffmpeg }
ffmpeg已正确安装在远程服务器上,并且可以在那里运行,但远程调用会导致错误:

ffmpeg : The term 'ffmpeg' is not recognized as the name of a cmdlet, function, script file, or operable program.
    + CategoryInfo          : NotSpecified: (ffmpeg : The te...rable program. :String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
    + PSComputerName        : transcodingserver

Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ ffmpeg
+ ~~~~~~
    + CategoryInfo          : ObjectNotFound: (ffmpeg:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
NotSpecified: (:) [], RemoteException

在我看来,如果我运行
Invoke命令的机器试图运行ffmpeg,而ffmpeg没有安装在那里。要在远程服务器上运行ffmpeg,您必须做什么?

您不需要
powershell
内部
-scriptblock{..}
,因为
调用命令本身是一个powershell会话(尽管是临时会话)。找到
ffmpeg
可执行文件的完整路径并运行以下命令

$session=new pssession-computername代码转换服务器
调用命令-session$session-scriptblock{&“C:\Program Files\ffmpeg\bin\ffmpeg.exe”}
或者您可以直接执行该命令,而无需
new pssession

Invoke命令-ComputerName代码转换服务器-scriptblock{
&“C:\Program Files\ffmpeg\bin\ffmpeg.exe”}

有一个类似的问题用

$media = Invoke-Command -ComputerName backupsvr -ScriptBlock { import-module "\program files\symantec\backup exec\modules\bemcli\bemcli"; Get-BEMedia}