c# - what is this format for seconds XXXXXXX.XXXXX:XXX (Win32_NetworkLoginProfile) -
querying wmi object on
$colitems = get-wmiobject win32_networkloginprofile -namespace "root\cimv2" | where-object {$_.name -match "name"} | select-object name,passwordage according msdn
passwordage
data type: datetime
access type: read-only
length of time password has been in effect. value measured number of seconds elapsed since password last changed.
example: 00001201000230.000000 000
i getting
00000068235223.000000:000 so have tried casting timespanand datetime no luck. colon represent how number hours represent.
thanks adding wmi class name title next poor soul confused documentation wording.
here works
that worked $str = "00000068235223.000000:000" $ts = [system.management.managementdatetimeconverter]::totimespan($str)
days : 68 hours : 23 minutes : 52 seconds : 23 milliseconds : 0 ticks : 59611430000000 totaldays : 68.9947106481481 totalhours : 1655.87305555556 totalminutes : 99352.3833333333 totalseconds : 5961143 totalmilliseconds : 5961143000
this dmtf time interval format documented here. string encodes time span in form ddddddddhhmmss.mmmmmm:000. note time intervals, ending :000.
from docs:
the following example shows format of date-time interval. ddddddddhhmmss.mmmmmm:000
following table lists fields of date-time interval.
field description
dddddddd 8 digits represent number of days (00000000 through 99999999).
hh two-digit hour of day uses 24-hour clock (00 through 23).
mm two-digit minute in hour (00 through 59).
ss two-digit number of seconds in minute (00 through 59).
mmmmmm six-digit number of microseconds in second (000000 through 999999).
i believe documentation misleading field, since implying whole numbers full seconds, in fact string format representing days, hours, minutes, seconds, etc.
you should use [system.management.managementdatetimeconverter]::totimespan convert string .net timespan, however, whatever reason received array instead of string passwordage, had use this:
$p = gwmi win32_networkloginprofile [system.management.managementdatetimeconverter]::totimespan($p.passwordage[1])
Comments
Post a Comment