none
Scheduled Maintenace Mode for selected Objects, and all their contained objects in Powershell RRS feed

  • Question

  • Hi Together

    I have a Problem with the Scheduled Maintenance Mode. I try to set a Maintenance Mode via PowerShell. I look for a Agent with get-agent and then i set the Scheduled Maintenance:

    New-SCOMMaintenanceSchedule-ActiveStartTime$time-Duration60-FreqType1-MonitoringObjects$agent-Name Test-ReasonCodePlannedOther-Enabled


    But how can i say in the PS-Command, that i wanna use the option "for selected Objects, and all their contained Objects? I have this Option when I set the Maintenance Mode in the GUI.

    Best Regards


    Wednesday, May 22, 2019 1:03 PM

Answers

  • Hi,

    you have a parameter "-Recursive", which means the following:

    from:

    New-SCOMMaintenanceSchedule

    "Indicates whether the schedule is applicable to the top level resource or to all the contained resources. If the recursive parameter is set to false, only the specified resource will go into maintenance mode when the schedule is run. If this is set to true, the specified resource and all resources that have a containment relationship with this resource will also go into maintenance mode."

    So if you put

    -Recursive $True

    you will set the maintenance mode also for all contained objects.

    This should help you out. Regards,


    (Please take a moment to "Vote as Helpful" and/or "Mark as Answer" where applicable. This helps the community, keeps the forums tidy, and recognizes useful contributions. Thanks!) Blog: https://blog.pohn.ch/ Twitter: @StoyanChalakov


    Wednesday, May 22, 2019 1:34 PM
    Moderator

All replies

  • Hi,

    you have a parameter "-Recursive", which means the following:

    from:

    New-SCOMMaintenanceSchedule

    "Indicates whether the schedule is applicable to the top level resource or to all the contained resources. If the recursive parameter is set to false, only the specified resource will go into maintenance mode when the schedule is run. If this is set to true, the specified resource and all resources that have a containment relationship with this resource will also go into maintenance mode."

    So if you put

    -Recursive $True

    you will set the maintenance mode also for all contained objects.

    This should help you out. Regards,


    (Please take a moment to "Vote as Helpful" and/or "Mark as Answer" where applicable. This helps the community, keeps the forums tidy, and recognizes useful contributions. Thanks!) Blog: https://blog.pohn.ch/ Twitter: @StoyanChalakov


    Wednesday, May 22, 2019 1:34 PM
    Moderator
  • Thank you very much. It works :)
    Wednesday, May 22, 2019 2:47 PM
  • Hi,

    glad to help. Regards!


    (Please take a moment to "Vote as Helpful" and/or "Mark as Answer" where applicable. This helps the community, keeps the forums tidy, and recognizes useful contributions. Thanks!) Blog: https://blog.pohn.ch/ Twitter: @StoyanChalakov

    Wednesday, May 22, 2019 2:50 PM
    Moderator