Gam Deprovision help

203 views
Skip to first unread message

Todd Allen

unread,
Sep 11, 2023, 11:35:48 AM9/11/23
to GAM for Google Workspace
I'm looking to bulk deprovision chrome devices that have not already been Deprovisioned. Is there a way to check for any device found in a CSV file that has a status "NOT DEPROVISIONED".  Here is where i'm at in the script but not sure what is the NOT operand.

CSV header  SerialNumber
..list of SN..'s


gam redirect stdout ./output.txt multiprocess redirect stderr stdout multiprocess csv dprolist.csv gam update cros query "id:~~SerialNumber~~ status:NOT DEPROVISIONED" ou "/Deprovisioned" action deprovision_different_model_replace acknowledge_device_touch_requirement

....  lastSync: 2023-08-23T09:09:36-07:00
  serialNumber: 5CD014BM4M
  status: DEPROVISIONED
  model: HP Chromebook 11 G7 EE

IF  status: DEPROVISIONED is removed the error I get is this: 
Got 1 CrOS Device that matched query (id:5CD0147R4L)
CrOS Device: fa3995cf-b38b-4e68-8deb-59f92f71b3d1, Deprovision Failed: Illegal device state transition. 

Thank you everyone for all the kind help.

Ross Scroggs

unread,
Sep 11, 2023, 12:03:10 PM9/11/23
to google-ap...@googlegroups.com
Todd,

The API has no "not" concept so you have to use multiple steps
# Get current status and OU of devices to be deprovisioned
gam redirect csv ./crosstatus.csv multiprocess csv dprolist.csv gam print cros query "id:~~SerialNumber~~" fields id,status,orgunitpath
# Update OU for those devices not already in the OU
gam config csv_input_row_drop_filter "orgUnitPath:regex:/Deprovisioned" redirect stdout ./UpdateOU.txt multiprocess redirect stderr stdout csv crosstatus.csv gam update cros "~deviceId"  ou "/Deprovisioned"
# Deprovision those devices that are not already deprovisioned
gam config csv_input_row_drop_filter "status:regex:DEPROVISIONED" redirect stdout ./Deprovision.txt multiprocess redirect stderr stdout csv crosstatus.csv gam update cros "~deviceId"  action deprovision_different_model_replace acknowledge_device_touch_requirement

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 on the web visit https://groups.google.com/d/msgid/google-apps-manager/902fe194-60b6-43f3-a50a-1b0d16e4a8e3n%40googlegroups.com.

Todd Allen

unread,
Sep 11, 2023, 12:39:24 PM9/11/23
to GAM for Google Workspace
Thank you Ross, that worked perfectly for me.

Todd Allen

unread,
Sep 11, 2023, 1:19:07 PM9/11/23
to GAM for Google Workspace
here is an Odd result.  the CSV list of Serial Numbers that I wanted to Deprovision is 1056 devices. what I run the first line: gam redirect csv ./crosstatus.csv multiprocess csv dprolist.csv gam print cros query "id:~~SerialNumber~~" fields id,status,orgunitpath
and review the Crosstatus.csv it contains 1189 devices. 
what would cause an increase in devices found?  I noticed that as the output is scrolling through, I would get a few of these:  Got 0 CrOS Devices that matched query (id:5CDS0147V3B) and that device is in my list to dispose of, but I have found several that are truly active and being used by students by the DeviceID that should not be Deprovisioned showing up.

what would cause an addition of devices that are not in my list.

On Monday, September 11, 2023 at 9:03:10 AM UTC-7 Ross Scroggs wrote:

Ross Scroggs

unread,
Sep 11, 2023, 2:53:24 PM9/11/23
to google-ap...@googlegroups.com
Todd,

This query "id:~~SerialNumber~~" in the API is a prefix search, you're getting extra devices because some of the serial numbers are not complete 
or you have a device with a serial number ABC1234 and another device with serial number ABC12345

Ross
----
Ross Scroggs


Ross Scroggs

unread,
Sep 12, 2023, 9:41:44 AM9/12/23
to google-ap...@googlegroups.com
Todd,

Sort dprolist.csv and crostatus.csv by serial number. The extra rows in crosstatus.csv are a result of an incomplete serial number in dprolist.csv.

Ross
--
Reply all
Reply to author
Forward
0 new messages