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

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

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

`object script.getscriptsbyhosts(array hostIds)`

Deze methode maakt het mogelijk om scripts op te halen die beschikbaar zijn op de gegeven hosts.

::: noteclassic
Deze methode is beschikbaar voor gebruikers van elk type. Rechten
om de methode aan te roepen, kan worden ingetrokken in de instellingen van de gebruikersrol. Zie [Gebruiker
rollen](/manual/web_interface/frontend_sections/administration/user_roles)
voor meer informatie.
:::

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

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

`(string/array)` ID's van hosts om scripts voor te retourneren.

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

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

`(object)` Retourneert een object met host-ID's als eigenschappen en arrays van
beschikbare scripts als waarden.

::: notitietip
De methode breidt automatisch macro's uit in de
'bevestigingstekst'.
:::

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

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

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

[comment]: # ({78b8a18a-4b630539})
#### Haal scripts op via host-ID's

Haal alle scripts op die beschikbaar zijn op hosts "30079" en "30073".

Verzoek:

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

Antwoord:

```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})
### Bron

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

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