Skip to main content
All CollectionsCloudGen Access Docs
CloudGen Access CLI Client Usage Examples
CloudGen Access CLI Client Usage Examples
Barracuda Admin avatar
Written by Barracuda Admin
Updated over a year ago

Example 1: List all devices from username Alice

access-cli devices list -o json --list-all --tenant=f28ddc39-79e0-4c9e-bdda-3bbff44e6bec | jq '.[] | select( .user.name == "Alice" )'

Example output:

          {
            "brand": "Apple",
            "created_at": "2022-03-03T15:18:27.561Z",
            "enrollment_id": "3f0dfafe-f792-4aa4-8c27-6488b5b478e9",
            "hardware_model": "MacBookPro15,2",
            "id": "a6bb9a4f-4a63-4d18-95e5-3c522f7e4d87",
            "os": "macOS",
            "security_checks": [],
            "status": "enrolled",
            "updated_at": "2022-03-03T15:19:17.968Z",
            "user": {
              "id": 458,
              "name": "Alice" 
            }
          }

Example 2: List all devices created before <date> and limit result fields

access-cli devices list -o json --list-all | jq '.[] | select (.created_at <= "2021-01-01T00:00:00.000Z") | {User: .user.name, DeviceCreated: .created_at, Model: .hardware_model}'        

Example output:

          {
            "User": "Bob",
            "DeviceCreated": "2021-03-25T12:18:45.012Z",
            "Model": "MacBookPro16,1"
          }
          {
            "User": "Bob",  
            "DeviceCreated": "2021-03-25T12:21:38.140Z",
            "Model": "iPhone10,4"
          }
          {   
            "User": "Carol", 
            "DeviceCreated": "2021-05-19T14:23:13.430Z",
            "Model": "Latitude 7490"
          }

Example 3: List all devices and limit result fields

access-cli devices list -o json --list-all | jq '.[] | {User: .user.name, DeviceCreated: .created_at, Model: .hardware_model, OS: .os, OSVersion: .os_version, AppVersion: .app_version}'       

Example output:

  {
            "User": "Bob",
            "DeviceCreated": "2022-06-08T03:52:28.016Z",
            "Model": "iPhone12,8",
            "OS": "iOS",
            "OSVersion": "15.4.1",
            "AppVersion": "1.7.1"
          }
          {
            "User": "Alice",
            "DeviceCreated": "2022-06-07T17:40:45.392Z",
            "Model": "VMware Virtual Platform",
            "OS": "Windows",
            "OSVersion": "10.0.19044.1706",
            "AppVersion": "1.7.1"
          }
          {
            "User": "Bob",
            "DeviceCreated": "2022-05-19T05:37:39.850Z",
            "Model": "Latitude 7420",
            "OS": "Linux",
            "OSVersion": "20.04",
            "AppVersion": "1.7.0"
          }
          {
            "User": "Carol",
            "DeviceCreated": "2022-06-07T17:40:45.392Z",
            "Model": "VMware Virtual Platform",
            "OS": "Windows",
            "OSVersion": "10.0.19044.1706",
            "AppVersion": "1.7.1"
          }

Example 4: List all devices and limit result fields to ID

access-cli devices list -o json --list-all | jq -r '.[].id'
 Example output:
cef0a784-4bf3-4e17-a12b-ddd6cd97b4fb
aabcac11-4ffd-4718-93ed-f72e947cc94c
802148af-8972-4b49-ae27-f9e8fdb141d2
4c178510-5b83-45cf-baa1-6077c7ab9c77
61f4b76a-1193-4231-8d06-e56974326efe
4cced090-8cb7-4fdf-acf2-bab3a54ae437
d485ee8c-ca16-4c69-8074-fd114083487c
aff0732c-7217-4d89-ab6c-77ba3b2169ca
84307ab2-33a1-4f4a-89fa-7eb470077515

Example 5: List all devices that haven't reported for more than 7 days and limit result fields

./access-cli devices list -list-all -o json | jq '(now-3600*24*7) as $when | .[] | select(.last_report_at != null) | select(.last_report_at | sub(".[0-9]*Z$"; "Z")| strptime("%Y%m-%dT%H:%M:%SZ") | mktime < $when) | {User: .user.name, DeviceCreated: .created_at, Model: .hardware_model, LastReport: .last_report_at}'

Example output:

{ 
          "User": "Carol",
          "DeviceCreated": "2022-04-08T13:07:26.985Z",
          "Model": "MacBookAir10,1",
          "LastReport": "2022-06-02T18:27:43.000Z"
        }  
        {
          "User": "Bob",
          "DeviceCreated": "2022-06-08T03:52:28.016Z",
          "Model": "iPhone12,8",
          "LastReport": "2022-06-08T03:55:47.000Z"
        }
        {
          "User": "Alice",
          "DeviceCreated": "2022-05-26T18:21:44.543Z",
          "Model": "MacBookPro15,2",
          "LastReport": "2022-06-02T16:14:04.000Z"
        }
        { 
          "User": "Bob",
          "DeviceCreated": "2022-05-19T05:37:39.850Z",
          "Model": "Latitude 7420",
          "LastReport": "2022-06-08T07:12:23.000Z"
        } 

Example 6: Find the last time a particular user accessed a specific / any app

Find the UserID:

MY_USER_ID=$(access-cli users list -q stran@thisdomain.com -o json | jq -r '.[0].id') 

Find the resource id for the app name:

MY_RESOURCE_ID=$(access-cli resources list -q "My Example App" -o json | jq -r '.[0].id')

Retrieve the last access time for this UserID for this app:

access-cli records list --sort created_desc --filter-user-id $MY_USER_ID --filter-event-name accessProxyAdmittance -o json | jq '[.[] | select (.params.resource.id == $my_resource_id)][0]|\{User: .user.name, Resource: .params.resource.name, LastAccess: .date}' --arg my_resource_id "$MY_RESOURCE_ID"

Example output:

{
  "User": “Susan Tran”,
  "Resource": "My Example App",
  "LastAccess": "2023-09-12T15:50:13.000Z"
}

Example 7: Revoke all enrollment links from tenant

access-cli --tenant=f28ddc39-79e0-4c9e-bdda-3bbff44e6bec users list --list-all | access-cli --tenant=f28ddc39-79e0-4c9e-bdda-3bbff44e6bec users enrollment revoke

Example output:

            +-----+---------+          
            |  ID | Result  |
            +-----+---------+
            | 464 | success |
            | 368 | success |
            | 372 | success |
            | 373 | success |
            | 374 | success |   
            +-----+---------+
            (5 records)   

Example 8: Export list of enrolled users to a CSV file

./access-cli users list --filter-status enrolled -o csv      

Example output:

ID,Name,Email,Groups,Enabled,Status,EnrollmentStatus
1302,JThomas,jthomas@gmail.com,Corp,true,enrolled,revoked      
Did this answer your question?