2016-08-25 170 views
0

我嘗試連接遠程服務器,並使用此PowerShell命令連接遠程服務器,並執行腳本

Invoke-Command -ComputerName \\srvwebui3 -ScriptBlock { 
    Get-Process | Where-Object { 
     $_.Path -like "\\abd\net$\abd\versions\Bin\HttpServer.exe" 
    } | Stop-Process 
} 

它停止的過程,但我得到了執行它之後此錯誤消息:

Invoke-Command : One or more computer names is not valid. If you are trying to 
pass a Uri, use the -ConnectionUri parameter or pass Uri objects instead of 
strings. 
At C:\powerShell\stop-process.ps1:4 char:15 
+ Invoke-Command <<<< -ComputerName \\srvwebui3 -ScriptBlock { Get-Process | Where-Object {$_.Path -like "\\gaia\netlims$\Autolims\MainRls\Bin\HttpServer.exe"} | Stop-Process } 
    + CategoryInfo   : InvalidArgument: (System.String[]:String[]) [Invoke-Command], ArgumentException 
    + FullyQualifiedErrorId : PSSessionInvalidComputerName,Microsoft.PowerShell.Commands.InvokeCommandCommand
+1

從計算機名稱中刪除前導反斜槓。 –

回答

0

這裏有一個PowerShell代碼的工作:

Invoke-Command -ComputerName <computerName> -ScriptBlock { 
    Get-Process | Where-Object { 
      $_.Path -like \\bbb\abab$\bs\MainRls\Bin\HttpServer.exe" 
    } | 
    Stop-Process -Force 
} 
相關問題