SMS Schedule Token on service maintenance window

Joshi, Gururaja 0 Reputation points
2023-02-02T17:03:39.7533333+00:00

Step 1: Creating Token By using manual script since SMS_ST_NonRecurring not working
PS C:> ConvertFrom-CCMSchedule -ScheduleString 02822D0000080000

SmsProviderObjectPath : SMS_ST_NonRecurring

DayDuration : 0

HourDuration : 0

MinuteDuration : 0

IsGMT : False

StartTime : 2/2/2022 8:00:00 PM

Description : Occurs on 2/2/2022 8:00:00 PM

step2: Using Admin service API:

$CollectionID = ''
$CollectionSettingsAPI = "<host>/AdminService/wmi/SMS_CollectionSettings('$CollectionID')"
Service.AddMembershipRule"

Write-Output($CollectionSettingsAPI)

$CollectionSettingsBody = @{
  CollectionID   = $CollectionID;
  ServiceWindows = @(
    @{
      "@odata.type"     = "#AdminService.SMS_ServiceWindow";
      Name              = "test Service window";
      Description       = "Test updates";
      IsEnabled         = "true";
      ServiceWindowSchedules = '
      ServiceWindowType = 4;
    })
}
$newBody = $CollectionSettingsBody | ConvertTo-Json

Write-Output($newBody)
  $Response = Invoke-RestMethod -Method 'Post' -Uri $CollectionSettingsAPI -UseDefaultCredentials -Body $newBody -ContentType "application/json"

ERROR:

.\service_maintenance_window.ps1

    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,service_maintenance_window.ps1

C:\Development\ESP\powershell\service_maintenance_window.ps1 : Exception Message: The remote server returned an error: (500) Internal Server Error.
At line:1 char:1

  • .\service_maintenance_window.ps1

    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,service_maintenance_window.ps1

C:\Development\ESP\powershell\service_maintenance_window.ps1 : Exception Stack: at <ScriptBlock>, C:\Development\ESP\powershell\service_maintenance_window.ps1: line 63
at <ScriptBlock>, <No file>: line 1
At line:1 char:1

  • .\service_maintenance_window.ps1

    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,service_maintenance_window.ps1

Microsoft System Center
Microsoft System Center
A suite of Microsoft systems management products that offer solutions for managing datacenter resources, private clouds, and client devices.
818 questions
Microsoft Configuration Manager
0 comments No comments
{count} votes