This script is designed to manage Organizational Units (OUs) in a Google Workspace domain. It generates a detailed report of OUs and provides functionality to delete selected OUs, ensuring that deletion policies are followed (e.g., no users in OUs).
1. Generate a report of all OUs with:
- Name and Path
- User Count
- Deletion Eligibility (Y/N)
- Unique Org Unit ID (used for deletions)
- Marked for Deletion status
2. Delete OUs that are marked for deletion (if eligible).
3. Recursive deletion of empty child OUs before deleting parent OUs.
4. Prevention of parent OU deletion if any child OU contains users.
1. Open the Google Sheet where you want to manage your OU data.
2. Run the `onOpen` function to add the custom "OU Cleaner" menu.
3. Use the menu options to:
a. Generate a report of OUs and their user counts.
b. Delete OUs marked for deletion.
4. Mark OUs for deletion by placing "x" or "X" in the "Marked to be deleted" column (Column E).
5. Ensure the "Can Be Deleted" column (Column C) shows "Y" for eligible OUs.
6. Use the "Delete Empty OUs" menu option to delete marked OUs.
- Root OU ("/") cannot be deleted.
- Child OUs are deleted first to maintain hierarchy rules.
- Detailed logs are available in the script execution logs for debugging.