First of all, thank you, Ross, for taking the time to explain this entire process to me. I am always amazed by how generous you are with your time and expertise. Also, as an educator, I appreciate how you took the time to make sure I understood these commands and then asked me to be the one to provide the answers to my own questions. #SeeOneDoOneTeachOne :)
The problem
I have a pile of OUs (see my original post for the hierarchy) which contain Chromebooks and many of them are in the wrong OU. I want to reassign OUs (and verify AssetIDs while I'm at it), using data exported from my Asset Tracking database. So, I want to:
- Pull all of the Chromebooks out of the hierarchy of child OUs and place them in a temporary location, then...
- ...use a Google Sheet to update the AssetID and OU of each Chromebook, effectively "putting them all back where they belong."
This is complicated by the fact that I have the device's
serial numbers, but the Google API wants me to identify them by
deviceID, Luckily, GAM can use a serial to look up and then use a deviceID, which is cool. Read on. :)
Part One
The first command I used is:
gam update ou "Path/to/DestinationOU" move cros_ou_and_children "Path/to/SourceOU" quickcrosmove
This says, "Hey GAM, let's make a change to DestinationOU. The change we are going to make is to move all of the devices in SourceOU (and any OUs inside it) into DestinationOU. And let's do that using the quickcrosmove method (
more info), which means that we aren't doing to balk if there are any errors along the way."
Presto... the devices have moved and all of the other OUs are empty.
Part Two
Now it's time to update those Chromebooks. I want to verify their AssetIDs and assign them new OUs, all with data pulled from a Google Sheet I created. The schema of that sheet is simply:
assetid | serial | location | ou
This is fairly straightforward but Ross showed me some cool stuff here, too. Here is the command:
gam csv gsheet <username> id <sheetID> <sheetname> gam update cros cros_sn ~SN_Column assetID ~assetCol ou ~OU_col
There are two parts... each starts with "gam.:"
- The first part says, "Hey GAM, I have a Google Sheet, owned by the user named <username> with the ID <sheetID>. Inside, on the individual sheet called <sheetname>, there's some data I want to use for the second part of this command...
- ...which says, "GAM, for each row on that sheet, I want to update a ChromeOS device identified by the serial number in SN_Column. For each one, replace the assetID with the number from AssetCol and replace the OU with whatever is in OU_Col.
The cool, extra part here is the cros_sn command (
more info). That little guy tells GAM, "Look, I know you want a DeviceID, but I don't have one. So I'm going to provide you with a Serial Number. Just take that, go look up the associated DeviceID where ever you keep it and then use that device."
So, that's what I did, and it worked great. :)
Thanks again, Ross.
-SD