PSCCMClient
PSCCMClient copied to clipboard
ConvertFrom-CCMSchedule : Parsing Schedule String resulted in invalid type of 6
With certain schedules, I get the above error in MCM. I looked over the WMI and I don't see anything particular about this return value:
https://learn.microsoft.com/en-us/mem/configmgr/develop/reference/core/servers/configure/sms_scheduletoken-server-wmi-class
The value returned from the function looks like this:
SmsProviderObjectPath : DayDuration : 0 HourDuration : 4 MinuteDuration : 0 IsGMT : False StartTime : 7/28/2023 2:00:00 AM
To assist with this, I'll add a schedule token returned that generates the error: 005C7D4020331680
Adding some more to this, according to our MCM admins, Microsoft recently added the ability to add a "Days Offset" parameter to the options available for 'SMS_ST_RecurMonthlyByWeekday', which seems to have resulted in a new, but undocumented, SMS Provider for scheduling:
https://learn.microsoft.com/en-us/mem/configmgr/develop/reference/core/servers/configure/sms_st_recurmonthlybyweekday-server-wmi-class
I see nothing related to it following that link.
FYI- I was able to get the new recurrence type details from Microsoft. It is returned by using the Convert-CMSchedule cmdlet in the CM PowerShell module:
SmsProviderObjectPath : SMS_ST_RecurMonthlyByWeekdayBase Day : 3 DayDuration : 0 ForNumberOfMonths : 1 HourDuration : 4 IsGMT : False MinuteDuration : 0 OffsetDay : 2 StartTime : 7/28/2023 2:00:00 AM WeekOrder : 3
JFYI (it looks pretty quiet in here) I believe the "missing 6th type" should be parsed like this:
6 {
$Day = [Convert]::ToInt32($binaryRecurrence.Substring(13, 3), 2)
$ForNumberOfMonths = [Convert]::ToInt32($binaryRecurrence.Substring(16, 4), 2)
$WeekOrder = [Convert]::ToInt32($binaryRecurrence.Substring(20, 3), 2)
$Offset = [Convert]::ToInt32($binaryRecurrence.Substring(24, 2), 2)
$WeekRecurrence = switch ($WeekOrder) {
0 {
'Last'
}
default {
$(Get-FancyDay -Day $WeekOrder)
}
}
$MW['Description'] = [string]::Format('Occurs the {0} {1} of every {2} months effective {3}', $WeekRecurrence, $([DayOfWeek]($Day - 1)), $ForNumberOfMonths, $StartDateTimeObject)
$MW['Day'] = $Day
$MW['ForNumberOfMonths'] = $ForNumberOfMonths
$MW['WeekOrder'] = $WeekOrder
$MW['WeekRecurrence'] = $WeekRecurrence
$MW['Offset'] = $Offset
}
Feel free to put in a PR. Happy to review it and merge!