The Problem

It's not uncommon for schools and corporations to manage thousands of Chrome Devices, specifically Chromebooks. Moving these Chrome devices across organizational units (OU) is a technique for deploying different enterprise policies. For school environments, Chrome devices often follow the change of students' OUs as they grow up. That said, Google Admin Console can allow you move limited Chrome devices to an organizational unit at a time. If you need to migrate over thousands of devices, it's very inefficient.

Moving Chrome Devices to another OU from Google Admin Console is inefficient for large quantity
Moving Chrome Devices to another OU from Google Admin Console is inefficient for large quantity

The Solution

The following open source Google Apps Script can help you automate the process of moving all Chrome devices from one OU to another.


  1. Open
  2. Click New project.
  3. Name the script project in the title
  4. Copy and paste the following script to the script editor, overwriting existing function myFunction() {} code
  5. Modify the sourceOU and destinationOU variables to matching your own case. These are the OU paths in the format of /OU/SubOU/SubSubOU. The root domain is represented by /.
  6. Click Services in the left navigation panel
    1. Select Admin SDK API
    2. Click Add
  7. Click Save Google Apps Script project button in the toolbar
  8. Click Run
  9. It will ask for your permissions in the first run
  10. After you grant the permission, the script shall move all your chrome devices from the sourceOU to the destinationOU

Source code

 * Move all Chromebooks from one OU to another OU
 * Usage:
 * Replace the `sourceOU` and `destinationOU`
 * with your OU setup, in a format of /OU/SubOU/SubSubOU.
 * © 2021 xFanatical, Inc.
 * @license MIT
 * @version 1.0.0
const sourceOU = '/sourceOU'
const destinationOU = '/destinationOU'

function moveChromebooks() {
  let pageToken
  let page
  do {
    page = AdminDirectory.Chromeosdevices.list('my_customer', {
      maxResults: 100,
      pageToken: pageToken,
      orgUnitPath: sourceOU,
    let chromeosdevices = page.chromeosdevices
    if (chromeosdevices) {
      for (let i = 0; i < chromeosdevices.length; i++) {
        const chromeosdevice = chromeosdevices[i]
        Logger.log('Moving chromebook ID: %s; SN: %s', chromeosdevice.deviceId, chromeosdevice.serialNumber)
          orgUnitPath: destinationOU,
        }, 'my_customer', chromeosdevice.deviceId)
    } else {
      Logger.log('No chromebooks found.')
    pageToken = page.nextPageToken
  } while (pageToken)

If you're interested in extending functions or automating your tasks as much as possible on Google Workspace, please check out our code-free workflow automation software Foresight. We also provide custom apps script development services to increase your productivity. Please don't hesitate to contact us. It's our passion and expertise to assist you on Google Workspace.