Improve error message for Get-Service with an invalid ComputerName
See original GitHub issueFiled 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:
- Created 7 years ago
- Comments:11 (7 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This issue should probably be closed since issue #5090 which has been addressed in pull-request #5094
Yes,it can. But on the other hand, adding the new exception we improve the error handling.