0

I'm trying to connect a remote server and stop a process on it using this PowerShell command

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

but I got this error message after executing it:

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
  • 1
    Remove the leading backslashes from the computer name. Commented Aug 25, 2016 at 10:19

1 Answer 1

0

Here a PowerShell code that worked:

Invoke-Command -ComputerName <computerName> -ScriptBlock {
   Get-Process | Where-Object {
            $_.Path -like \\bbb\abab$\bs\MainRls\Bin\HttpServer.exe"
    } |
    Stop-Process -Force
} 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.