Querying a WMi object on the
$colItems = Get-WmiObject Win32_NetworkLoginProfile -Namespace "root\CIMV2"
| Where-Object {$_.name -match "Name"} | Select-Object name,PasswordAge
according to MSDN
PasswordAge
Data type: datetime
Access type: Read-only
Length of time a password has been in effect. This value is measured from the number of seconds elapsed since the password was last changed.
Example: 00001201000230.000000 000
I am getting
00000068235223.000000:000
So I have tried casting this to TimeSpanand DateTime no luck.
what does the colon represent how to get number hours it represent.
Thanks Adding the WMI class name to title for the next poor soul that get confused by documentation wording.
here is what works
That worked perfectly $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