Example


Conversion dates WMI size

How to convert a date in WMI format deviation [datetime] and vice-versa
Let me tell you how we can convert these dates when WMI queries that return a date.
The date format used by WMI is the standardized DMTF size.

Example

PS> (Get-WmiObject-class Cim_OperatingSystem).InstallDate
20080618021130.000000 +120

Copy and Try it

The result is a relatively easy to interpret dates. We can easily cut into small pieces and reformat a date in a expected format in PowerShell.

Here dotnet framework class come and rescue you System.Management.ManagementDateTimeConverter. Class does includes ToDateTime and method

Example

PS> $ DateInstallation = (Get-WmiObject-class Cim_OperatingSystem). InstallDate
PS> [System.Management.ManagementDateTimeConverter] :: ToDateTime ($ DateInstallation)

Wednesday, Jun 18, 2008 2:11:30 a.m.

Copy and Try it

How to get current datetime

Example

PS> $ DateHeureCourante = Get-Date

Copy and Try it