Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConvertFrom-CCMSchedule : Parsing Schedule String resulted in invalid type of 6 #57

Open
hsbrown2 opened this issue Sep 21, 2023 · 2 comments

Comments

@hsbrown2
Copy link

hsbrown2 commented Sep 21, 2023

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

@hsbrown2
Copy link
Author

hsbrown2 commented Oct 6, 2023

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
            }

@CodyMathis123
Copy link
Owner

Feel free to put in a PR. Happy to review it and merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants