locked
Scripting SCOM groups RRS feed

  • Question

  • Hi,

    I have the following situation:
    GroupA created in the Management PackA. I also have GroupB created in the Management PackB.
    GroupA is manually populated by specific objects of Windows Computer class.
    For some reason, I need that GroupB contains same members as GroupA. To minimize administrative effort in maintaining group membership on both places, is it possible to create and schedule PowerShell script for that purpose?

    Any help is greatly appreciated.

    Thanks a lot in advance,
    Vedran Matica
    Friday, February 5, 2010 6:16 PM

Answers

  • I don't have an example of this on hand, but it should be possible.

    To do this, you would need to do the following in an MP:

    1. Create a singleton class derived from Microsoft.SystemCenter.ComputerGroup (from the Microsoft.SystemCenter.Library MP)
    2. Create a discovery targeting Microsoft.SystemCenter.RootManagementServer that discovers instances of the Microsoft.SystemCenter.ComputerGroupContainsComputer relationship type for the group and each member of GroupA.


    Your PowerShell script for #2, needs to do the following:
    1. Use the SCOM SDK to find all the instances of Microsoft.SystemCenter.ComputerGroupContainsComputer for GroupA.
    2. Add corresponding instances of Microsoft.SystemCenter.ComputerGroupContainsComputer for GroupB based on what you found in #1.
    3. Return discovery data.


    It's not really recommended to run things on the RMS, but you can mitigate this by setting a large interval on the group discovery or by changing it into a task that you only run when you need to.
    This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm
    • Marked as answer by Vedran Matica Tuesday, February 9, 2010 7:29 AM
    Monday, February 8, 2010 7:51 PM

All replies

  • I don't have an example of this on hand, but it should be possible.

    To do this, you would need to do the following in an MP:

    1. Create a singleton class derived from Microsoft.SystemCenter.ComputerGroup (from the Microsoft.SystemCenter.Library MP)
    2. Create a discovery targeting Microsoft.SystemCenter.RootManagementServer that discovers instances of the Microsoft.SystemCenter.ComputerGroupContainsComputer relationship type for the group and each member of GroupA.


    Your PowerShell script for #2, needs to do the following:
    1. Use the SCOM SDK to find all the instances of Microsoft.SystemCenter.ComputerGroupContainsComputer for GroupA.
    2. Add corresponding instances of Microsoft.SystemCenter.ComputerGroupContainsComputer for GroupB based on what you found in #1.
    3. Return discovery data.


    It's not really recommended to run things on the RMS, but you can mitigate this by setting a large interval on the group discovery or by changing it into a task that you only run when you need to.
    This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm
    • Marked as answer by Vedran Matica Tuesday, February 9, 2010 7:29 AM
    Monday, February 8, 2010 7:51 PM
  • Marcin,

    Thank you very much for your reply.

    Regards,
    Vedran

    Tuesday, February 9, 2010 7:30 AM