DSCResources/src/cWmiAbsoluteTimer.1.0.Resource.ps1
Write-DSCResource -Property @{ TimerId = 'An identifier for the timer' EventDateTime = 'The datetime of the event', [DateTime] SkipIfPassed = 'Indicates if the event should fire after the event has passed', [bool] } -Test { $existingTimer = Get-WmiObject -Namespace root\cimv2 -Class __AbsoluteTimerInstruction -Filter "TimerID = '$TimerID'" $existingTimer -and $existingTimer.EventDateTime -eq $existingTimer.ConvertFromDateTime($EventDateTime) -and $existingTimer.TimerID -eq $TimerID -and $existingTimer.SkipIfPassed -eq $SkipIfPassed } -Get { $existingTimer = Get-WmiObject -Namespace root\cimv2 -Class __AbsoluteTimerInstruction -Filter "TimerID = '$TimerID'" if (-not $existingTimer) { return @{} } return @{ TimerID = $existingTimer.TimerID SkipIfPassed = $existingTimer.SkipIfPassed EventDateTime = $existingTimer.ConvertToDateTime($existingTimer.EventDateTime) } } -Set { $wmiClass = [wmiclass]'__AbsoluteTimerInstruction' $newInstance = $wmiClass.CreateInstance() $newInstance.TimerID = $timerID $newInstance.EventDateTime = $newInstance.ConvertFromDateTime($eventDateTime) $newInstance.SkipIfPassed = $skipIfPassed $null = $newInstance.Put() } -KeyProperty TimerID -MandatoryProperty IntervalBetweenEvents |