locked
Create Instance Groups using PowerShell from csv. RRS feed

  • Question

  • I did not find much on this topic, so here is what I was able to accomplish. I needed a way to automate group creation when a new account team was added to our ticketing system/service manager. I found pieces of information here and there but nothing concrete. The following was the best I came up with for anyone else struggling with this. There are some things I am still trying to figure out, like using membership rules for query based membership, this script only handles direct membership, but hey at least it is a start. 

    (WARNING) The new-scgroup cmdlet will not append to an existing MP, so you will end up with a MP for each group....otherwise it just overwrites the existing MP. 

    $CI = get-scsmobject -Id "guid of your object for direct membership"
    $groups = Import-Csv "mycsvpath.csv"
    foreach ($group in $groups) {
    New-SCGroup -Name $group.Account -ManagementPackName $Group.Account -Include $CI -Description $Group.Description -GroupType InstanceGroup -import}

    The CSV file has two columns, Account and Description in this, but it can be whatever you want, just be sure to update the variables with your names in the New-SCGroup parameters. This is also setup for the -Include or Direct Membership with the $CI variable. 



    Bryan McCuen


    Tuesday, September 10, 2019 7:55 PM

All replies

  • Hi Bryan,

    thanks for sharing this. It will be a lot easier to "read" the code if you also format it as a code, using the option on the bar. :)

    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


    Friday, September 13, 2019 8:22 AM
  • Thanks for the pointer! Much appreciated!

    Bryan


    Bryan McCuen

    Monday, September 16, 2019 9:42 PM