From 9a79eb7de28709c5dc54eebd90e39fc8ffaec6d1 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Mon, 22 Jan 2024 23:24:23 +0000 Subject: [PATCH] add run script api powershell --- docs/functions/api.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/functions/api.md b/docs/functions/api.md index 2ace449d..44a7a33e 100644 --- a/docs/functions/api.md +++ b/docs/functions/api.md @@ -159,6 +159,36 @@ Here are some examples: } ``` +???+ abstract "Example: Run a script on an agent" + + === ":material-powershell: PowerShell" + + ```powershell + $apiUrl = 'https://api.example.com/agents/CHANGEME/runscript/' + + $jsonPayload = @{ + output = "wait" + emails = @() + emailMode = "default" + custom_field = $null + save_all_output = $false + script = 20 + args = @() + env_vars = @() + run_as_user = $false + timeout = 90 + } | ConvertTo-Json + + + $headers = @{ + 'Content-Type' = 'application/json' + 'X-API-KEY' = 'changeme' + } + + $response = Invoke-RestMethod -Uri $apiUrl -Method Post -Body $jsonPayload -Headers $headers + $response + ``` + ## API via CLI