Moving devices from root OU to multiple other OUs

117 views
Skip to first unread message

Garrett Ralston

unread,
Sep 1, 2023, 4:24:38 PM9/1/23
to GAM for Google Workspace
Hi, I'm new to GAM, and don't speak command line all that well haha.. I'm needing to move a bunch of devices from our root OU to multiple other OUs. I have a csv file that has "SerialNumber" and "TargetOU" headers, with all of the SNs, and each of the target OUs. I can reach all of my target OUs and my root OU using the "gam info org #" command, where # is the particular path.

When I run my batch file, this is what I get in the command line:
 moving 1 devices to //TargetOU

ERROR: 400: Invalid Input: INVALID_OU_ID - invalid
PyInstaller\loader\pyimod02_importers.py:352: UserWarning: You are using cryptography on a 32-bit Python on a 64-bit Windows Operating System. Cryptography will be significantly faster if you switch to using a 64-bit Python.
 moving 1 devices to //Students/Elementary/PJE/PK


This is what I have in my batch file:
@echo off
set GAM_PATH="C:\GAM\gam.exe"
set CSV_FILE=C:\Users\ralstong\Documents\chromebooks.csv
set SOURCE_OU=/

rem Ensure you have the necessary headers in the CSV file:
rem SerialNumber,TargetOU

rem Loop through the CSV file and move each Chromebook from the root OU to its target OU
for /f "tokens=1,2 delims=," %%i in (%CSV_FILE%) do (
    "%GAM_PATH%" update cros %%i org "%SOURCE_OU%/%%j"
)

echo Chromebooks moved from %SOURCE_OU% to their target OUs based on the CSV file.

I'm unsure of where I'm going wrong since I can reach each OU individually. Is it that I'm using regular GAM rather than Advanced GAM?

Ross Scroggs

unread,
Sep 1, 2023, 4:30:30 PM9/1/23
to google-ap...@googlegroups.com
Garrett,

gam csv "C:\Users\ralstong\Documents\chromebooks.csv" gam update cros cros_sn "SerialNumber" ou "~TargetOU"

Show a sample line from you CSV file.

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/74dcc4e6-ad53-48ce-b32a-048984336ef9n%40googlegroups.com.

Ralston, Garrett

unread,
Sep 1, 2023, 4:41:34 PM9/1/23
to google-ap...@googlegroups.com
Hi Ross,

Here's a sample from my CSV:
SerialNumberTargetOU
JSMG9W3
Students/Elementary/PJE/PK
BY9K9W3
Students/Elementary/PJE/KG
FM22J93
Students/Elementary/PJE/01

I have 6 additional OUs which I'm moving devices into as well.

The line you shared, is that all I would need in my batch file?


You received this message because you are subscribed to a topic in the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-manager/W8jWix0Shz4/unsubscribe.
To unsubscribe from this group and all its topics, 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/A9676E94-C725-4EB4-BFBF-303D5812BF20%40gmail.com.


--
Thanks,
Garrett Ralston
Technology Specialist II
One to One Coordinator
Pryor Public Schools
(918) 825-3997 Direct Line

Ross Scroggs

unread,
Sep 1, 2023, 4:50:45 PM9/1/23
to google-ap...@googlegroups.com
Garrett,

Basically, yes; but you're using Standard GAM, the error message indicates a potential bug.

Send me a Meet/Zoom invitation to discuss.

Ross



--
Reply all
Reply to author
Forward
0 new messages