Solved

policies and group export

  • 8 December 2023
  • 14 replies
  • 101 views

Badge

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

 

icon

Best answer by MarkH-Automox 8 December 2023, 22:45

View original

14 replies

Userlevel 4
Badge

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).

Badge

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 ?

Userlevel 4
Badge

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

Badge

 

Userlevel 4
Badge

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
 

 

Badge

still get same error

Badge

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

Userlevel 4
Badge

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)

 

 

Badge

thanks, does this need to be edited

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

Userlevel 4
Badge

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

Badge

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

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

 

Userlevel 4
Badge

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 

Badge

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

Userlevel 4
Badge

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

 

Reply