Improve quality of ErrorRecord object contents - by David Wyatt

Status : 


Sign in
to vote
ID 792975 Comments
Status Active Workarounds
Type Suggestion Repros 0
Opened 7/7/2013 7:16:36 PM
Access Restriction Public


Some cmdlets in PowerShell v3 produce non-terminating errors that don't contain enough information to identify exactly what was being attempted when the error occurred.  Get-WmiObject is a good example;  if it encounters an "RPC Server is unavailable" message for one of the computers in the -ComputerName argument, the ErrorRecord object which is produced does not contain the ComputerName value anywhere:  TargetObject is null.  CategoryInfo.TargetName and CategoryInfo.TargetType are empty strings.  InvocationInfo.BoundParameters and InvocationInfo.UnboundArguments are empty collections.

There may be other cmdlets that have odd error reporting behavior as well.  Get-Service, for example, does not produce any errors when it can't contact a computer specified in the -ComputerName argument, so long as it was able to successfully contact at least one computer and obtain the specified services.
Sign in to post a comment.