link icon
Ask The Community

TeamViewer is one of the winners of the European Customer Centricity Award 🥳

Please find more information here.

Creating Groups using a script

HeinM Posts: 9 ✭✭

I need to create about 3000 groups for the retail division in the management console. Is there a script that I can use to import these groups from a csv file?

Best Answer


  • W_deFazio
    W_deFazio Posts: 22 Staff member 🤠

    Hello HeinM ,

    Thank you for your post.

    That is possible with the API, for the available API calls please see .

    Do you need to just create groups, or also add contacts/machines to these groups all from the CSV file?


  • HeinM
    HeinM Posts: 9 ✭✭

    I already have the users on the system and am importing them in bulk using a csv file. But now I have been asked to create a group per store and populate the groups with the machines. All the devices have a unique id that I can use, ie 002701, Group name = "002701 - Brackenfell" and pc name is ad002701e001. The ideal would be to be able to create subgroups, but that is still a dream.

  • W_deFazio
    W_deFazio Posts: 22 Staff member 🤠

    Hello HeinM,

    If I understood correctly, you already have the devices on the contacts list, and you just need to create groups now so you can later move the devices to the designated groups.

    I created a simple Powershell script that will create the groups for you by importing the names of the groups from a .csv file.

    The default of the script is looking for a file named "import.txt" in the C: drive of the machine where you run the script from. But if you want to name the file something else, and have it call it from a different location, just edit the line ($data = Import-Csv "C:\import.txt") with the name and path of your file.

    You will need to edit the script by replacing the word "UserToken" with the API token created with user account level from the TeamViewer account you want to create the groups in. 

    To create the API token with User level, please do the following:

    - Sign in with your TeamViewer account on the Management Console(
    - On the top right of the page click on the blue button with the user name and profile picture
    - Click on "Edit profile"
    - Go to "Apps"
    - Then "Create script token"
    - Select the permissions and click Save.


    $header = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
    $header.Add("authorization", 'Bearer UserToken')

    $data = Import-Csv "C:\import.txt"

    $body = $data
    Foreach($item in $body)
    $name = $
    $body = (@{
    name = "$name"
    }) | ConvertTo-Json
    Invoke-RestMethod -Uri "" -Method Post -Headers $header -ContentType application/json -Body $body

    For the import.txt file, it should look like this:


    Hope it helps!