Spaces method and path for this operation:
Refer to Spaces for more information.
Run a script on a host. Currently supported only for some agent types.
Body
Required
-
List of agent types to retrieve. Defaults to
endpoint.Values are
endpoint,sentinel_one,crowdstrike, ormicrosoft_defender_endpoint. -
If this action is associated with any alerts, they can be specified here. The action will be logged in any cases associated with the specified alerts. Max of 50.
At least
1but not more than50elements. Minimum length of each is1. -
The IDs of cases where the action taken will be logged. Max of 50.
At least
1but not more than50elements. Minimum length of each is1. -
Optional comment
-
List of endpoint IDs (cannot contain empty strings). Max of 250.
At least
1but not more than250elements. Minimum length of each is1. parameters
object Required One of the following set of parameters must be provided for the
agentTypethat is specified.One of: Elastic Defend Run Script Parametersobject Security_Endpoint_Management_API_RawScriptParametersobject Security_Endpoint_Management_API_HostPathScriptParametersobject Security_Endpoint_Management_API_CloudFileScriptParametersobject SentinelOne Run Script Parametersobject Microsoft Defender Endpoint Run Script Parametersobject -
Parameters object
curl \
--request POST 'https://<KIBANA_URL>/api/endpoint/action/runscript' \
--header "Authorization: $API_KEY" \
--header "Content-Type: application/json" \
--data '{"agent_type":"endpoint","endpoint_ids":["ed518850-681a-4d60-bb98-e22640cae2a8"],"parameters":{"scriptId":"1111-2222-3333-4444-5555-6666-7777-8888","scriptInput":"--path= /usr/log/exec.log"}}'
{
"agent_type": "endpoint",
"endpoint_ids": [
"ed518850-681a-4d60-bb98-e22640cae2a8"
],
"parameters": {
"scriptId": "1111-2222-3333-4444-5555-6666-7777-8888",
"scriptInput": "--path= /usr/log/exec.log"
}
}
{
"agent_type": "microsoft_defender_endpoint",
"endpoint_ids": [
"ed518850-681a-4d60-bb98-e22640cae2a8"
],
"parameters": {
"args": "-param1 value1 -param2 value2",
"scriptName": "my-script.ps1"
}
}
{
"agent_type": "sentinel_one",
"endpoint_ids": [
"ed518850-681a-4d60-bb98-e22640cae2a8"
],
"parameters": {
"scriptId": "1111-2222-3333-4444-5555-6666-7777-8888",
"scriptInput": "--delete --paths-to-delete /tmp/temp_file.txt,/tmp/random_file.txt"
}
}
{
"data": {
"agents": [
"ed518850-681a-4d60-bb98-e22640cae2a8"
],
"agentState": {
"ed518850-681a-4d60-bb98-e22640cae2a8": {
"isCompleted": false,
"wasSuccessful": false
}
},
"agentType": "sentinel_one",
"command": "runscript",
"createdBy": "elastic",
"hosts": {
"ed518850-681a-4d60-bb98-e22640cae2a8": {
"name": "gke-node-1235412"
}
},
"id": "233db9ea-6733-4849-9226-5a7039c7161d",
"isCompleted": false,
"isExpired": false,
"outputs": {},
"parameters": {
"scriptId": "1111-2222-3333-4444-5555-6666-7777-8888"
},
"startedAt": "2022-07-29T19:08:49.126Z",
"status": "pending",
"wasSuccessful": false
}
}