Get-Pingstatus Expandproperty Statuscode

Jul 23, 2012 at 1:25 PM
Edited Jul 23, 2012 at 2:30 PM

Hi Kirk,

with Get-Pingstatus I receive the statuscode.

I want to ask if it is possible to "expand" the property (in this case it is a codeproperty) statuscode to receive the human readable meaning of the value.

http://msdn.microsoft.com/en-us/library/windows/desktop/aa394350%28v=vs.85%29.aspx

11002

Destination Net Unreachable

11003

Destination Host Unreachable

11004

Destination Protocol Unreachable

Unfortunately I did not find a possibility to do this

PS C:\Windows\system32> $c.StatusCode
11010
PS C:\Windows\system32> $c.StatusCode | Get-Member


TypeName: System.UInt32

Name        MemberType Definition
----        ---------- ----------
CompareTo   Method     int CompareTo(System.Object value), int CompareTo(System.UInt32 value)
Equals      Method     bool Equals(System.Object obj), bool Equals(System.UInt32 obj)
GetHashCode Method     int GetHashCode()
GetType     Method     type GetType()
GetTypeCode Method     System.TypeCode GetTypeCode()
ToString    Method     string ToString(), string ToString(System.IFormatProvider provider), string ToString(string format), string ToString(string format, System.IFormatProvider provider)

 


PS C:\Windows\system32> $c| Format-Custom -Depth 2

class ManagementObject#ROOT\cimv2\Win32_PingStatus
{
  Address =myip
  BufferSize = 32
  NoFragmentation = False
  PrimaryAddressResolutionStatus = 0
  ProtocolAddress =
  ProtocolAddressResolved =
  RecordRoute = 0
  ReplyInconsistency =
  ReplySize =
  ResolveAddressNames = False
  ResponseTime =
  ResponseTimeToLive =
  RouteRecord =
  RouteRecordResolved =
  SourceRoute =
  SourceRouteType = 0
  StatusCode = 11010
  Timeout = 4000
  TimeStampRecord =
  TimeStampRecordAddress =
  TimeStampRecordAddressResolved =
  TimestampRoute = 0
  TimeToLive = 128
  TypeofService = 0
}

regards

 

Andreas

Jul 24, 2012 at 8:34 PM

Hi Andreas,

Yes, this is possible, and thanks for asking because I had meant to do this but forgot about it.  I've just started investigating it to see how quickly I can put it in because I think it's really important, and I'll post back once I've figured out when I'll get this done.

Kirk out.

Jul 24, 2012 at 8:35 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Jul 26, 2012 at 4:11 AM

FYI, I implemented this today so that you get meaningful enumeration values in cases like this for all of the WMI functions/objects that are generated with wmix.  This change will be in the next release I post.

Jul 26, 2012 at 11:42 AM

Thanks for improving this feature.