AutomoxAutomox

policies and group export

curioustoknow
December 8, 2023 at 6:09 pm UTC

How do you export current policies and groups in automox. I don’t see any options available to this in the platform.

 

This discussion is archived and closed to replies. Continue it in the Automox Community Slack.

Discuss on Slack

Replies (14)

MarkH-AutomoxDecember 8, 2023
#1

Hello,

While we dont have an export button for the groups and policies, there are two API calls we can issue to collect that information:
https://developer.automox.com/openapi/axconsole/operation/getServerGroups/

https://developer.automox.com/openapi/axconsole/operation/getPolicies/

The request samples on the right hand side include the actual command you can copy and paste. (insert orgID and API key).

curioustoknowDecember 8, 2023
#2

Do tou run this from the developer.automox.com and just change the org ID and api Key and should return the information I need ?

MarkH-AutomoxDecember 8, 2023
#3

Yes, copy the code for the respective language you want to use and the substitute the variables.

curioustoknowDecember 8, 2023
#4

 

MarkH-AutomoxDecember 8, 2023
#5

Hello,

You will need to copy each line into a text file and save it as a .ps1 script. Once you do that, you would execute it by typing ‘./mygroupscript.ps1’ to get the results.

You could put it at the top of a powershell ISE window as well in the Script Pane
 

 

curioustoknowDecember 8, 2023
#6

still get same error

curioustoknowDecember 8, 2023
#7

i put the org ID and API key on the develoer.automox.com, its returning some results but I cant export or read it properly

MarkH-AutomoxDecember 8, 2023
#8

I occasionally see the no response error when the org value is not in the original request. I have added my query and response here. Responses are JSON payloads and do require some formatting. There are some options in powershell to convert to CSV (example)

 

 

curioustoknowDecember 8, 2023
#9

thanks, does this need to be edited

$url = "https://console.automox.com/api/servergroups?o=0000"

MarkH-AutomoxDecember 8, 2023
#10

It doesn’t have to be, it is different in my example since i just grabbed another more detailed example I had handy.

curioustoknowDecember 8, 2023
#11

got the json resulrs and when trying to convert its doent work.

i basically copied the results to notepad and renamed the file ,json

 

MarkH-AutomoxDecember 8, 2023
#12

Hello,

I grabbed an example from a different community Worklet allowing the initial output to already be formatted much more cleanly. Append  ConvertFrom-Json  to the $response line:
 

 $response = (Invoke-WebRequest -Method Get -Uri $url -Headers $headers).Content | ConvertFrom-Json

echo $response 

curioustoknowDecember 8, 2023
#13

Thanks Mark, making a lot of progress here. how can i export this into a csv for better readng

MarkH-AutomoxDecember 8, 2023
#14

I got this to work with the following:

 $logFilePath = 'C:\Temp\groups.csv'
$response = (Invoke-WebRequest -Method Get -Uri $url -Headers $headers).Content | ConvertFrom-Json
$output += $response
$output | Export-Csv -Path $logFilePath -NoTypeInformation -Force