2014-06-06 32 views
0

我試圖通過PowerShell來調用遠程代碼轉換服務器上的ffmpeg:呼叫遠程小命令(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

你不需要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"} 
0

也有類似的問題與

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