Using a csv file of device SN's

166 views
Skip to first unread message

Paul D'Hondt

unread,
Sep 16, 2021, 3:43:42 PM9/16/21
to GAM for Google Workspace
Hi everyone,
I'm trying to use a csv of over 1000 devices (serial numbers), and get a printout file of which ou each are in. (see below for why). Since I have SN's and not deviceid, I need to use query:id in there too.

I can't seem to figure out a way to do this. any thoughts? I've tried:
gam info cros query:id:serialnumberhere fields orgunitpath targetfolder c:\gam\testoutput
and 
gam print cros query:id:LR048CS6 fields orgunitpath (but it doesn't like a query when using print)

(I used Gam to move 1023 devices to a new ou.. but only 999 moved - I imagine a limit in google? - so I need to know which of the 1023 devices did'nt get moved so I can move them into an alternative ou).

Ross Scroggs

unread,
Sep 16, 2021, 4:11:00 PM9/16/21
to google-ap...@googlegroups.com
Paul,

This will give you all of the Chromebooks that aren't already in the correct OU; substitute your OU for /StudentChromebooks
Basic GAM:

set GAM_CSV_ROW_DROP_FILTER=orgUnitPath:regex:/StudentChromebooks

gam print cros query "id:LR048CS6" fields deviceid,orgunitpath,serialnumber > testoutput.csv

Advanced GAM:
gam config csv_output_row_drop_filter "orgUnitPath:regex:/StudentChromebooks" redirect csv ./testoutput.csv print cros query "id:LR048CS6" fields deviceid,orgunitpath,serialnumber

Verify that testoutput.csv makes sense.

Now you can move these to the correct OU.
gam update ou /StudentChromebooks croscsvfile ./testoutput.csv:deviceId

Ross

--
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 on the web visit https://groups.google.com/d/msgid/google-apps-manager/1e522646-1aa1-4c1a-a876-0489eeab921en%40googlegroups.com.


--

Paul D'Hondt

unread,
Sep 17, 2021, 9:01:21 AM9/17/21
to GAM for Google Workspace
oh wow thanks Ross. Do I run this command each time for each device (like from a batch file?)

Ross Scroggs

unread,
Sep 17, 2021, 9:24:14 AM9/17/21
to google-ap...@googlegroups.com
Paul,

Let's call your serial number file crossns.csv with a column serialNumber

This will give you all of the Chromebooks that aren't already in the correct OU; substitute your OU for /StudentChromebooks
Basic GAM:
set GAM_CSV_ROW_DROP_FILTER=orgUnitPath:regex:/StudentChromebooks
gam csv crossns.csv gam print cros query "id:~~serialNumber~~" fields deviceid,orgunitpath,serialnumber > testoutput.csv
Edit testoutput.csv and delete all of the duplicate header rows, leave the one at the top: deviceId,serialNumber,orgUnitPath

Advanced GAM:
gam config csv_output_row_drop_filter "orgUnitPath:regex:/StudentChromebooks" redirect csv ./testoutput.csv multiprocess csv crossns.csv gam print cros query "id:~~serialNumber~~" fields deviceid,orgunitpath,serialnumber
testoutput.csv is ready to use, no editing required.

Verify that testoutput.csv makes sense.

Now you can move these to the correct OU.
gam update ou /StudentChromebooks croscsvfile ./testoutput.csv:deviceId

Paul D'Hondt

unread,
Sep 17, 2021, 9:32:00 AM9/17/21
to GAM for Google Workspace
many thanks. It's greatly appreciated!

Paul D'Hondt

unread,
Sep 17, 2021, 1:26:52 PM9/17/21
to GAM for Google Workspace
I'm using Basic gam, and I get "ERROR: Query:id:1234567 is not a valid argument for "gam print cros"". 
I had to add the additional colon, but it doesn't work without it either. (from the code above, it gave me "Error: queryid:123456 is not a valid argument" error.

Ross Scroggs

unread,
Sep 17, 2021, 1:44:39 PM9/17/21
to google-ap...@googlegroups.com
Paul,

What is: gam version

Ross



--

Paul D'Hondt

unread,
Sep 17, 2021, 3:19:10 PM9/17/21
to GAM for Google Workspace
a very, very old one. thanks for your help Ross.
Reply all
Reply to author
Forward
0 new messages