Automate your group creation with Powershell

One of our very good customers are managing servers with an dedicated internal administrator as a primary contact for each server. They are managing this one to one relation with an Excel sheet. A while ago we talked about automating this group creation with powershell, so the last time Jacob and I was discussing Powershell in Operations Manager we found a solution – Jacob who is the best Danish Powershell Guru of cause did a superoptimization of my first script and now its up to you to test it on your own.

Please change the first lines of the script to your environment.

Download script:

Download “Group Creation Powershell” GroupsFromExcelSheet.zip – Downloaded 2954 times – 28 KB

About the Author:

Kåre Rude Andersen
Microsoft Certified Trainer since 1996, MCSE, TS and ITP in Microsoft Windows, SQL (also Microsoft), Exchange (MS) and Microsoft Operations Manager. Senior Consultant and have recently worked as a consultant at CSC, SAS, ISS, Nokia and Scandlines.

8 Comments

  1. Scott November 23, 2010 at 19:47 - Reply

    When I run the script it is not finding computers that are in the OpsDB. any troubleshooting tips?

  2. Andreas Rentsch December 20, 2010 at 14:05 - Reply

    Very good idea – I tried it but there are some little errors in the script. I will share it with you:

    1) Check Language Settings if Excel Workbook errors occurs

    2) The scripts finds no agents with this line “cd (“Monitoring:” + (get-rootmanagementserver).Principalname)”, but with this line ”
    cd (“Monitoring:” + (get-rootmanagementserver).Principalname + “Microsoft.SystemCenter.AgentManagedComputerGroup”)”

    unfortunatly I got another error while creating the groups:

    Exception calling “InsertCustomMonitoringObjectGroup” with “1” argument(s): “Processing the template failed. See inner exception for details.”
    At C:tempGroupsFromExcelSheet.ps1:166 char:40
    + $mp.InsertCustomMonitoringObjectGroup <<<< ($group)
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

    Any idea on this?

    Regards
    Andy

    • Marc March 14, 2013 at 16:08 - Reply

      *push*
      I ran into the exact same problem where you able to solve this ?

      Greetings Marc

  3. Dave March 30, 2012 at 16:50 - Reply

    How would one modify this script to add to an already existing group?

  4. Surya July 18, 2014 at 18:44 - Reply

    Got into the same problem as Marc and Andreas.
    Any ideas please.

  5. Richard B January 13, 2017 at 15:05 - Reply

    Could you please suggest for the following:

    $namespace = ‘Coretech.Test’ <– I understand this is the Group Name you want to give
    $opsMgrDrive = "Monitoring:ctops.coretech.intra" <—-What information should I use here related to my environment?

    Thank you very much!

  6. Kelly March 31, 2017 at 15:23 - Reply

    The article is Automate your group creation with Powershell but the linked script it group creation through Exce.

  7. alice March 6, 2018 at 13:49 - Reply

    PS C:\> $mp.InsertCustomMonitoringObjectGroup($group)
    Exception calling “InsertCustomMonitoringObjectGroup” with “1” argument(s): “Processing the template failed. See inner
    exception for details.”
    At line:1 char:38
    + $mp.InsertCustomMonitoringObjectGroup <<<< ($group)
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

Leave A Comment