Comparing ConfigMgr Date Formats in PowerShell

If you have worked with ConfigMgr much, you know that uses WMI to stores tons of information.  WMI uses the CIM_DATETIME format, which looks like this: yyyymmddHHMMSS.mmmmmmsUUU.  In order to work with this in PowerShell, you need to convert it into something that the Get-Date cmdlet can understand.  Here are two ways that you can accomplish this:

Using the ManagementDateTimeConverter Class:

get-date ([system.management.managementdatetimeconverter]::todatetime('20141004185400.000000+***'))

or by using the ConvertToDateTime() method:

([wmi]"").ConvertToDateTime('20141004185400.000000+***')

And here is an example for a required deployment policy comparing the EnforcementDeadline to the current date:

$EnforcementDate = Get-WmiObject -Namespace "root\ccm\Policy\Machine\RequestedConfig" -Class CCM_ApplicationCIAssignment | Where-Object { (($_.AssignmentName -eq 'My Application_Install') -and ($_.EnforcementDeadline -ne $null))}
$DeadlinePast = $EnforcementDate.ConvertToDateTime($y.EnforcementDeadline) -lt (Get-Date)

Originally posted on https://miketerrill.net/

IT-DevConnections Session Links

Last month I had the honor of speaking at my first ever IT/Dev Connections in sunny Las Vegas.  I had the pleasure of presenting on Building the Ultimate Operating System Task Sequence with my coworker and good friend Troy Martin.  As promised, we have completed publishing a series of blogs on all the topics in our session.  We managed to pack a bunch into the session and you can find each of the blogs listed below:

Including Pre-Flight Checks in Your Ultimate Task Sequence

ConfigMgr 2012: Always including certain files in your Boot Images

ConfigMgr 2012 OSD: Automatically Open SMSTS log

ConfigMgr 2012 R2 OSD: Create Your Own TS Templates

I am already looking forward to next year.  It was a great conference with lots of familiar faces and reminded me of the early MMS days.

Originally posted on https://miketerrill.net/