Endpoint: /sites/{siteId}/custom-commands/{customCommandID}
NOTE: Available as of EFT 8.1.0
Returns a custom command defined on an EFT site and allows the ability to get, patch (update), and delete the custom command.
-
GET
-
PATCH
-
DELETE
Method & URL
GET https://[server URL]:[port]/admin/v2/sites/{siteId}/custom-commands/{customCommandID}
GET Body Sample
Copy
### Get Custom Commands for a Site ###
# @name customCommandList
GET https://{{host}}/admin/v2/sites/{{Siteid}}/custom-commands HTTP/1.1
Authorization: EFTAdminAuthToken {{AuthToken}}
###
@customCommandID = {{customCommandList.response.body.$.data[0].id}}
### Get specific Custom Command from a Site ###
GET https://{{host}}/admin/v2/sites/{{Siteid}}/custom-commands/{{customCommandID}} HTTP/1.1
Authorization: EFTAdminAuthToken {{AuthToken}}
###
GET Response Body Sample
Copy
{ "data": { "id": "9a0c4aec-862e-4e72-aec4-9b1f04f00bb3", "type": "customCommand", "attributes":
{ "enabled": true, "name": "Command 1", "description": "this is a test to run command 1",
"executable": "c:\\windows\\system32\\cscript.exe \"c:\\users\\administrator\\desktop\\server.vbs\"",
"parameters": "", "redirectOutputToLog": true, "useProcessTimeOut": true, "processTimeOut": 30,
"logFileName": "C:\\ProgramData\\Globalscape\\EFT Server\\Logs\\cmdout.log",
"redirectOutputToClient": true, "useMinNumOfParams": false, "minNumOfParams": 1,
"minNumOfParamsMsg": "" }, "relationships": { "executionPermissions": { "data": { "users": [],
"userGroups": [ { "type": "userGroup", "id": "a0db9377-92a3-4a38-8c0f-09f268d78ff1", "meta":
{ "name": "All Users" } } ] } } }, "links": { "self":
"/admin/v2/sites/c7d3ecfe-a100-4bcd-b830-01a10524c048/custom-commands/9a0c4aec-862e-4e72-aec4-9b1f04f00bb3" } } }
GET PowerShell Sample
Copy
###
#Get Site Custom Commands
Write-Output "Get Site Custom Commands"
Write-Output "-----"
$commands = Invoke-RestMethod -Uri "$baseURL/v2/sites/$siteID/custom-commands"
-Method 'GET' -Headers $authHeader
#Write-Output $serverAdminDetails | ConvertTo-Json -Depth 10
foreach ($commands in $commands.id)
{
Write-Output ("Custom Command found: $($commands.id): $($commands.attributes.name)")
}
$customCommandID = $commands.data[0].id
###
#Get Custom Command
Write-Output "Get Custom Commands for: " $customCommandID
Write-Output "-----"
$commandList = Invoke-RestMethod -Uri "$baseURL/v2/sites/$siteID/custom-commands/$customCommandID"
-Method 'GET' -Headers $authHeader
Write-Output $commandList | ConvertTo-Json -Depth 10
Method & URL
PATCH https://[server URL]:[port]/admin/v2/sites/{siteId}/custom-commands/{customCommandID}
PATCH Body Sample
Copy
### Get Custom Commands for a Site which is needed to patch a Custom Commmand ###
# @name customCommandList
GET https://{{host}}/admin/v2/sites/{{Siteid}}/custom-commands HTTP/1.1
Authorization: EFTAdminAuthToken {{AuthToken}}
###
@customCommandID = {{customCommandList.response.body.$.data[0].id}}
###
#Path Custom Command on a specific EFT site
PATCH https://{{host}}/admin/v2/sites/{{Siteid}}/custom-commands/{{customCommandID}} HTTP/1.1
Authorization: EFTAdminAuthToken {{AuthToken}}
{
"data":{
"id":"",
"type": "customCommand",
"attributes": {
"enabled": true,
"name": "Updated Custom Command Name",
"description": "Updated Custom Command Description",
"executable": "c:\\windows\\system32\\cscript.exe \"c:\\users\\administrator\\desktop\\server.vbs\"",
"parameters": "",
"redirectOutputToLog": true,
"useProcessTimeOut": false,
"processTimeOut": 30,
"logFileName": "C:\\ProgramData\\Globalscape\\EFT Server\\Logs\\cmdout.log",
"redirectOutputToClient": true,
"useMinNumOfParams": false,
"minNumOfParams": 1,
"minNumOfParamsMsg": ""
}
}
}
###
PATCH Response Body Sample
Copy
{ "data": { "id": "9a0c4aec-862e-4e72-aec4-9b1f04f00bb3", "type": "customCommand", "attributes":
{ "enabled": true, "name": "Updated Custom Command Name", "description": "Updated Custom Command Description",
"executable": "c:\\windows\\system32\\cscript.exe \"c:\\users\\administrator\\desktop\\server.vbs\"",
"parameters": "", "redirectOutputToLog": true, "useProcessTimeOut": false, "processTimeOut": 30,
"logFileName": "C:\\ProgramData\\Globalscape\\EFT Server\\Logs\\cmdout.log",
"redirectOutputToClient": true, "useMinNumOfParams": false, "minNumOfParams": 1, "minNumOfParamsMsg": "" },
"relationships": { "executionPermissions": { "data": { "users": [], "userGroups": [
{ "type": "userGroup", "id": "a0db9377-92a3-4a38-8c0f-09f268d78ff1",
"meta": { "name": "All Users" } } ] } } }, "links": { "self":
"/admin/v2/sites/c7d3ecfe-a100-4bcd-b830-01a10524c048/custom-commands/9a0c4aec-862e-4e72-aec4-9b1f04f00bb3" } } }
PATCH PowerShell Sample
Copy
############################
#Patch a Custom Command
###
#Get Site Custom Commands
Write-Output "Get Site Custom Commands in order to Patch"
Write-Output "-----"
$commands = Invoke-RestMethod -Uri "$baseURL/v2/sites/$siteID/custom-commands" -Method 'GET' -Headers $authHeader
#Write-Output $serverAdminDetails | ConvertTo-Json -Depth 10
foreach ($commands in $commands.id)
{
Write-Output ("Custom Command found: $($commands.id): $($commands.attributes.name)")
}
$customCommandID = $commands.data[0].id
#PATCH Custom Command
Write-Output "Custom Command Patch"
Write-Output "Custom Command: $customCommandID"
Write-Output "-----"
$update =
'{
"data":{
"id":"",
"type": "customCommand",
"attributes": {
"enabled": true,
"name": "Updated Custom Command Name 2",
"description": "Updated Custom Command Description 2",
"executable": "c:\\windows\\system32\\cscript.exe \"c:\\users\\administrator\\desktop
\\server.vbs\"",
"parameters": "",
"redirectOutputToLog": true,
"useProcessTimeOut": false,
"processTimeOut": 30,
"logFileName": "C:\\ProgramData\\Globalscape\\EFT Server\\Logs\\cmdout.log",
"redirectOutputToClient": true,
"useMinNumOfParams": false,
"minNumOfParams": 1,
"minNumOfParamsMsg": ""
}
}
}'
$update = $update | ConvertFrom-Json
$update = $update | ConvertTo-Json -Depth 10
$patchReturn = Invoke-RestMethod -Uri "$baseURL/v2/sites/$siteID/custom-commands/$customCommandID"
-Method 'PATCH' -Headers $authHeader -Body $update
Method & URL
DELETE https://[server URL]:[port]/admin/v2/sites/{siteId}/custom-commands/{customCommandID}
DELETE Body Sample
Copy
##DELETE Custom Commands
### Get Custom Commands for a Site which is needed to delete a Custom Commmand ###
# @name customCommandList
GET https://{{host}}/admin/v2/sites/{{Siteid}}/custom-commands HTTP/1.1
Authorization: EFTAdminAuthToken {{AuthToken}}
###
@customCommandID = {{customCommandList.response.body.$.data[0].id}}
#
##Delete Request passing custom command id
DELETE https://{{host}}/admin/v2/sites/{{Siteid}}/custom-commands/{{customCommandID}} HTTP/1.1
Authorization: EFTAdminAuthToken {{AuthToken}}
DELETE Response Body Sample
Copy
HTTP/1.1 204 No Content Date: Fri, 15 Jul 2022 21:48:08 GMT Content-Length: 0
Cache-Control: no-cache, no-store, must-revalidate Expires: -1
X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block
Content-Security-Policy: default-src 'self' 'unsafe-inline' 'unsafe-eval' data:;
Referrer-Policy: no-referrer
DELETE PowerShell Sample
Copy
### DELETE CUSTOM COMMAND
#Get Site Custom Commands in order to get custom command id
Write-Output "Get Site Custom Commands in order to Delete"
Write-Output "-----"
$commands = Invoke-RestMethod -Uri "$baseURL/v2/sites/$siteID/custom-commands"
-Method 'GET' -Headers $authHeader
#Write-Output $serverAdminDetails | ConvertTo-Json -Depth 10
foreach ($commands in $commands.id)
{
Write-Output ("Custom Command found: $($commands.id): $($commands.attributes.name)")
}
$customCommandID = $commands.data[0].id
Write-Output "Deleting Custom Command: " $customCommandID
Write-Output "-----"
$commandList = Invoke-RestMethod -Uri "$baseURL/v2/sites/$siteID/custom-commands/$customCommandID"
-Method 'DELETE' -Headers $authHeader
Write-Output $commandList | ConvertTo-Json -Depth 10