Query syntax with csv gsheet varaible

34 views
Skip to first unread message

Joshua Squires

unread,
May 15, 2026, 3:41:07 PMMay 15
to GAM for Google Workspace
I am attempting to delete retired devices from the company owned devices section in the Admin Console. I have a large amount of devices so I am trying to delete them through GAM. I have a gsheet with a list of serial numbers. I am having issues using this with a gam command. 

After some trial and error I have found the correct format of the command to delete the records. Now I am attempting to delete them in bulk using the csv gsheet option. When I run the following it doesn't appear to be replacing the variable with the serial numbers. 

gam csv gsheet <us...@domain.com> <Document_ID> <Sheet_Name> gam delete device query "serial:~sn" doit

The output just shows the same two lines over and over again:

Getting all Devices that match query (serial:~sn), may take some time on a large Google Workspace Account...
Got 0 Devices...

I can confirm that the values I have for the user, Document_ID and sheet name are correct because if I remove "query "serial:" form the command and just leave ~sn the output shows the serial numbers. However it fails because it needs the query to work.  

Is it possible to include the variable in the query?


Ross Scroggs

unread,
May 15, 2026, 7:13:03 PMMay 15
to google-ap...@googlegroups.com
You want: gam csv gsheet <us...@domain.com> <Document_ID> <Sheet_Name> gam delete device query "serial:~~sn~~" doit

Ross
----
Ross Scroggs



--
You received this message because you are subscribed to the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/google-apps-manager/c54328f0-3ba6-4459-9757-db0d099e8f79n%40googlegroups.com.

Joshua Squires

unread,
May 18, 2026, 10:42:36 AMMay 18
to GAM for Google Workspace
Thanks for that, it worked on getting the variable to be pulled in. 

However, it appears that I am only able to find devices with an Assigned status with but I am not able to find them if they are unassigned.  I have user " gam print device query "serial:<serialNumber> " to confirm this . I see the devices in the inventory list but the command doesn't appear to be able to find it. I have about 400+ devices that have been retired and I'm hoping I don't have to do this one by one through the Admin Console. It looks like I'm back at step one.

If anyone has any insight on how to delete stale devices that happen to show an "Unassigned" status in the Company Owned Devices inventory in bulk I'm open to suggestions. 

GAM 7.35.00
Python 3.14.3 64-bit final
Windows 11 10.0.26200 SP0 Multiprocessor Free AMD64

Reply all
Reply to author
Forward
0 new messages