Important note: If the owner account has been permanently deleted (deleted more than 20 days ago), there is less management possible. If it's within the 20 days, you can temporarily restore the account, and then have full management of the course. Afterwards, delete is the only option.
For recently deleted users (less than 20 days), you can't even print their specific courses.
gam print courses teacher username
This will come back with an "invalid argument" for deleted users.
So you will have to print all courses, which may take a very long time, depending on how many courses you have, and how many such deleted owners you have. Each unknown owner causes a significant delay in the process.
For that specific purpose I created a script to only list courses with unknown owners, so called orphaned courses.
#!/bin/bash
# Add a dated sheet to the file Orphaned Classrooms with Classrooms without owner in my Workspace
GAM="/Users/kim/gamadv-xtd3/gam"
$GAM select lomma save
$GAM redirect csv ./CourseIDs.csv print courses fields id
$GAM config num_threads 30 redirect csv - multiprocess todrive tdfileid SheetIDhere tdtitle "Orphaned Classooms" tdtimestamp true tdsheet "" tdaddsheet tdsheettimeformat %Y%m%d csv ./CourseIDs.csv gam print courses course "~id" fields id,name,owneremail,teachers owneremailmatchpattern "Unknown User"
$GAM select default save
The list is added to a Sheet I keep for managing orphaned Classrooms. It still needs to print all courses, but it filters the list to only unknown owners and pushes that data to the Sheet.
Since the data adds up, you may have to create a new one after a few years; depending on the size of your Workspace you may hit the 10M cells limitation.
The data will also list secondary teachers, so I have someone to reach out to and ask whether it's ok if I delete the course, as that is the only viable option when the user is permanently deleted.
Last I checked, you can't manage the course in any other way at that time. Delete is the only option.
Yes, I use a very high number of threads for this command, and that's because running the command in sequence and not parallel would take forever, and experience have shown that even though you almost immediately run into quota delays, the total time spent will be lower with this number of threads. I haven't tested max number of threads, as it is taxing on the computer, and I want to be able to do other things in the meantime.
--
https://wheretofind.me/@NoSubstitute