question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve error message for Get-Service with an invalid ComputerName

See original GitHub issue

Filed on UserVoice: http://windowsserver.uservoice.com/forums/301869/suggestions/17193962

The error message for Get-Service returns a NoServiceFoundForGivenName exception even when the problem is an invalid -ComputerName, potentially misleading the user.

Steps to reproduce

Get-Service wuauserv -ComputerName MadeUpComputerName

Expected behavior

Get-Service : Cannot find any computer with name 'MadeUpComputerName'.
At line:1 char:1
+ Get-Service wuauserv -ComputerName MadeUpComputerName
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (wuauserv:String) [Get-Service], ServiceCommandExce
   ption
    + FullyQualifiedErrorId : SomeOtherExceptionForComputerNameNotFound,Microsoft.PowerShell.Commands.GetService
   Command

Actual behavior

Get-Service : Cannot find any service with service name 'wuauserv'.
At line:1 char:1
+ Get-Service wuauserv -ComputerName MadeUpComputerName
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (wuauserv:String) [Get-Service], ServiceCommandExce
   ption
    + FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.GetService
   Command

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSRemotingProtocolVersion      2.3
PSVersion                      6.0.0-alpha
WSManStackVersion              3.0
BuildVersion                   3.0.0.0
SerializationVersion           1.1.0.1
PSEdition                      Core
GitCommitId                    v6.0.0-alpha.12
CLRVersion
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
joandrsncommented, Oct 24, 2017

This issue should probably be closed since issue #5090 which has been addressed in pull-request #5094

1reaction
iSazonovcommented, Dec 11, 2016

Yes,it can. But on the other hand, adding the new exception we improve the error handling.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get-Service error - Microsoft Q&A
Get-Service -ComputerName Lenovo17. I get, the following error: Get-Service : Cannot open Service Control Manager on computer 'Lenovo17'.
Read more >
Can't use Get-Service –ComputerName on remote computer
A small set of commands in PowerShell v2 have a -ComputerName ... your error message by attempting to run Get-Service -ComputerName MyServer ...
Read more >
Why does this powershell command using Get-Service not ...
If the server is inaccessible or not found, the first statement prints an error message and continues. As I understand the ErrorAction by ......
Read more >
Use PowerShell to find Windows services configured to run ...
Learn how to use Invoke-Command and Get-CIMInstance to find all services running as another user.
Read more >
Understanding and troubleshooting WinRM connection and ...
An error occurred executing a remote WinRM command. Shell: Cmd Command: hostname. Message: The requested address is not valid in its context. - ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found