SCOM dynamic group based on AD group - standalone script instead of MP

madhavi gunasekar 41 Reputation points
2020-11-25T07:03:21.73+00:00

Hi

Am looking for Standalone powershell script for SCOM group based on AD groups.

I could find management pack for this but instead , is there a powershell script available . If so ..please share the details.

Script is available in MP , but how can i provide values to sourceID and managemententity id from SCOM.

Regards
Madhu

Operations Manager
Operations Manager
A family of System Center products that provide infrastructure monitoring, help ensure the predictable performance and availability of vital applications, and offer comprehensive monitoring for datacenters and cloud, both private and public.
1,481 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,522 questions
0 comments No comments
{count} votes

7 answers

Sort by: Most helpful
  1. SChalakov 10,386 Reputation points MVP
    2020-11-25T08:16:54.133+00:00

    Hi @madhavi gunasekar ,

    I suppose you are talking about the script Kevin Holman referenced in his blog:

    How to create a SCOM group from an Active Directory Computer Group
    https://kevinholman.com/2017/08/26/how-to-create-a-scom-group-from-an-active-directory-computer-group/

    Both of the properties you have mentioned are comming from the discovery module:

    # Load SCOM Discovery module  
    $DiscoveryData = $momapi.CreateDiscoveryData(0, $SourceId, $ManagedEntityId)  
    

    exactly because of this, if you want to test the script you need to provide zeroed values for those:

    # Manual Testing section - put stuff here for manually testing script - typically parameters:  
    #=================================================================================  
    # $SourceId = '{00000000-0000-0000-0000-000000000000}'  
    # $ManagedEntityId = '{00000000-0000-0000-0000-000000000000}'  
    # $ADGroup = "SCOM Computers Group"  
    # $LDAPSearchPath = "LDAP://DC=opsmgr,DC=net"  
    #=================================================================================  
    

    Please examine the script and the comments of Kevin Holman and try to run it. Let us know how it looks like.

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
    Regards,
    Stoyan

    0 comments No comments

  2. madhavi gunasekar 41 Reputation points
    2020-12-01T11:21:04.353+00:00

    Thanks Stoyan

    I have run the script and it executes fine. Also , success event id 7500 created .

    But would this create group in SCOM ? Am planning to run the script using powershell instead of importing management pack.

    Regards
    Madhavi

    0 comments No comments

  3. CyrAz 5,181 Reputation points
    2020-12-01T16:48:50.707+00:00

    No you can't simply run that script outside of scom to get the groups created.
    That script works by outputing property bags. These can only be interpreted by scom's internal powershell engine.
    There actually should be a way to modify that script so it would directly work with the SDK to instanciate the groups, but I strongly advise you against that solution and therefore I won't detail it any further.
    Why don't you want it to run inside of SCOM? It's much more dynamic and flexible that way...

    0 comments No comments

  4. madhavi gunasekar 41 Reputation points
    2020-12-02T07:08:31.597+00:00

    Thanks for your suggestion.

    Basically , we want the script to run outside of SCOM to modify whenever required. Instead of AD , we might need to get the input from other tools or applications.

    Also , $ADGroup = "SCOM Computers Group" , how can we input multiple AD groups here. Do we need to create separate fragments for each AD group and subgroups , inside MP.

    Regards
    Madhavi

    0 comments No comments

  5. CyrAz 5,181 Reputation points
    2020-12-02T19:52:09.57+00:00

    I would use either separate fragments or an additional foreach loop in the script, depending on the scenario...
    Remember that a Management Pack should contain "stuff" related to a single application, as a general rule.
    So if the same "application" needs to create multiple groups, I may use a single fragment with multiple groups.
    Otherwise I would use different fragments.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.