[comment]: # ({e5a46c74-e5a46c74})
# script.getscriptsbyhosts

[comment]: # ({/e5a46c74-e5a46c74})

[comment]: # ({dfaa829b-dfaa829b})
### Descripció

`object script.getscriptsbyhosts(array hostIds)`

Aquest mètode permet recuperar scripts disponibles a l'equip donat.

::: noteclassic
Aquest mètode és disponible per a qualsevol mena d'usuaris. Els permisos per cridar al mètode es poden revocar a la configuració de rols d'usuaris. Per a més informació, veieu [Rols d'usuari](/manual/web_interface/frontend_sections/administration/user_roles).
:::

[comment]: # ({/dfaa829b-dfaa829b})

[comment]: # ({080ad0f7-080ad0f7})
### Paràmetres

`(string/array)` IDs dels equips dels que es recuperaran els scripts.

[comment]: # ({/080ad0f7-080ad0f7})

[comment]: # ({1c891d1a-1c891d1a})
### Valors de retorn

`(object)` Retorna un objecte amb ID d'equip com a propietats i matrius d'scripts disponibles com a valors.

::: notetip
El mètode ampliarà automàticament les macros al text de `confirmation`.
:::

[comment]: # ({/1c891d1a-1c891d1a})

[comment]: # ({b41637d2-b41637d2})
### Exemples

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({78b8a18a-4b630539})
#### Recuperar scripts per ID d'equip

Recuperar tots els scripts disponibles dels equips "30079" i "30073".

Petició:

```json
{
    "jsonrpc": "2.0",
    "method": "script.getscriptsbyhosts",
    "params": [
        "30079",
        "30073"
    ],
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Resposta:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "30079": [
            {
                "scriptid": "3",
                "name": "Detect operating system",
                "command": "sudo /usr/bin/nmap -O {HOST.CONN} 2>&1",
                "host_access": "2",
                "usrgrpid": "7",
                "groupid": "0",
                "description": "",
                "confirmation": "",
                "type": "0",
                "execute_on": "1",
                "hostid": "10001"
            },
            {
                "scriptid": "1",
                "name": "Ping",
                "command": "/bin/ping -c 3 {HOST.CONN} 2>&1",
                "host_access": "2",
                "usrgrpid": "0",
                "groupid": "0",
                "description": "",
                "confirmation": "",
                "type": "0",
                "execute_on": "1",
                "hostid": "10001"
            },
            {
                "scriptid": "2",
                "name": "Traceroute",
                "command": "/usr/bin/traceroute {HOST.CONN} 2>&1",
                "host_access": "2",
                "usrgrpid": "0",
                "groupid": "0",
                "description": "",
                "confirmation": "",
                "type": "0",
                "execute_on": "1",
                "hostid": "10001"
            }
        ],
        "30073": [
            {
                "scriptid": "3",
                "name": "Detect operating system",
                "command": "sudo /usr/bin/nmap -O {HOST.CONN} 2>&1",
                "host_access": "2",
                "usrgrpid": "7",
                "groupid": "0",
                "description": "",
                "confirmation": "",
                "type": "0",
                "execute_on": "1",
                "hostid": "10001"
            },
            {
                "scriptid": "1",
                "name": "Ping",
                "command": "/bin/ping -c 3 {HOST.CONN} 2>&1",
                "host_access": "2",
                "usrgrpid": "0",
                "groupid": "0",
                "description": "",
                "confirmation": "",
                "type": "0",
                "execute_on": "1",
                "hostid": "10001"
            },
            {
                "scriptid": "2",
                "name": "Traceroute",
                "command": "/usr/bin/traceroute {HOST.CONN} 2>&1",
                "host_access": "2",
                "usrgrpid": "0",
                "groupid": "0",
                "description": "",
                "confirmation": "",
                "type": "0",
                "execute_on": "1",
                "hostid": "10001"
            }
        ]
    },
    "id": 1
}
```

[comment]: # ({/78b8a18a-4b630539})

[comment]: # ({a62657e4-a62657e4})
### Font

CScript::getScriptsByHosts() in
*ui/include/classes/api/services/CScript.php*.

[comment]: # ({/a62657e4-a62657e4})
