通过Invoke-Command调用远程cmdlet(ffmpeg):“...未被识别为名称...”

时间:2014-06-06 14:13:16

标签: 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 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-Command,试图运行ffmpeg,它没有安装在那里。你需要做什么,在远程服务器上运行ffmpeg?

2 个答案:

答案 0 :(得分:2)

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

$session = new-pssession -computername transcodingserver
Invoke-Command -session $session -scriptblock { & "C:\Program Files\ffmpeg\bin\ffmpeg.exe"}

或者您可以直接执行命令,而不需要new-pssession

Invoke-Command -ComputerName transcodingserver -scriptblock { 
    & "C:\Program Files\ffmpeg\bin\ffmpeg.exe"}

答案 1 :(得分:0)

有一个类似的问题用

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