You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2023-06-12 09:13:31

ComLu
Member
Registered: 2020-01-28
Posts: 65

GLPI Inventory plugin find computers ID from computers name

Hello,

I have a CSV with about 100 computer's names.

I need to create a Static computer groups to do a deploy.

The problem is that I can import only a CSV with computers' IDs, is there a way to get ID by computernames without doing it one by one?

Offline

#2 2023-06-14 02:27:24

cconard96
Moderator
Registered: 2018-07-31
Posts: 2,813
Website

Re: GLPI Inventory plugin find computers ID from computers name

You would need to use the GLPI API for that.
You could make a script to loop through each name, search for computers with that name through the API, and get the ID from the result.

You can enable the API and see the documentation for in in Setup > General in the API tab.


GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.

Offline

#3 2023-06-14 09:28:14

ComLu
Member
Registered: 2020-01-28
Posts: 65

Re: GLPI Inventory plugin find computers ID from computers name

I have tried but the search replies without indication of the id (in this case I know that the id I have to discover is 6043).

I used:
http://glpi/apirest.php/search/Computer/?&criteria[0][link]=AND&criteria[0][field]=1&criteria[0][searchtype]=contains&criteria[0][value]=PCNAME&itemtype=Computer&start=0&session_token=mysessiontoken

Reply with:

{
    "totalcount": 1,
    "count": 1,
    "sort": [
        "1"
    ],
    "order": [
        "ASC"
    ],
    "data": [
        {
            "1": "NB-USERNAME",
            "126": [
                "10.22.11.64",
            ],
            "7": "username@NB-USERNAME",
            "70": null,
            "46": "2009",
            "61": "64-bit",
            "40": "20RW",
            "5": "LR84V81E",
            "31": null
        }
    ],
    "content-range": "0-0/1"
}

Maybe I'm searching in the wrong way?

Last edited by ComLu (2023-06-14 09:48:33)

Offline

#4 2023-06-14 09:47:48

ComLu
Member
Registered: 2020-01-28
Posts: 65

Re: GLPI Inventory plugin find computers ID from computers name

Solved:

http://glpi/apirest.php/Computer/?expand_dropdowns=true&session_token=mysessiontoken&searchText[name]=PCNAME

Last edited by ComLu (2023-06-14 09:48:09)

Offline

Board footer

Powered by FluxBB