This script is designed to manage Google Workspace Organizational Units (OUs).
- Create OUs and nested OUs based on paths provided in a Google Sheet.
- List all existing OUs and their details in another sheet.
- Create OUs from a hierarchical slash-based path (e.g., /Top/Sub/Deeper).
- Automatically creates missing parent OUs in the path.
- Uses IDs to handle cases where the domain uses ID-based orgUnitPaths.
- List all current OUs with details such as: Name, ID, Full Path, Parent ID, and User Count.
Start by copying this Google Sheet.
Then open the Google Sheet and Look for the OU Creator Menu.
Start by run the List Current OUs. The first time you will need authenticate using Google Workspace account (must be a super admin account).
Aimed for listing OUs if you run the List Current OUs function.
- Use OU Creator Menu > List Current OUs to create or update the "OU listing" sheet.
- Name: The OU name.
- OrgUnitID: The unique ID of the OU.
- OrgUnitPath: The full path of the OU (may be ID-based in some domains).
- ParentOrgUnitId: The parent OU’s unique ID.
- UserCount: Number of users directly in the OU.
- Column A: Input the full path of the OUs you want to create (e.g., /Top, /Top/Sub, /Top/Sub/Deeper).
- Column B: Leave empty. The script will write the final OU ID or an error message here.
Populate Column A of "OU Creation" with the desired OU paths, starting in row 2. For example:
/Top
/Top/Sub
/Top/Sub/Deeper
/ExistingRoot/TeamAlpha
- Go to the menu OU Creator Menu > Create OUs from Sheet.
- The script will create all the specified OUs (and their parents, if needed) and log the final OU ID or error in Column B.
- If a top-level OU cannot be created (e.g., due to domain restrictions), you’ll see "Invalid Ou Id" in Column B.