SCRT-HQ / PSGSuite

Powershell module for Google / G Suite API calls wrapped in handy functions. Authentication is established using a service account via P12 key to negate the consent popup and allow for greater handsoff automation capabilities
https://psgsuite.io/
Apache License 2.0
234 stars 67 forks source link

Google Classroom - Sync-GSCourse #334

Open Foggy2 opened 3 years ago

Foggy2 commented 3 years ago

Hi @scrthq and others,

As I get time I have been trying to rework my bodged together scripts into something that is modular and contains cleaner code/comments with a view to offering them for inclusion in the module.

The first script I am tackling is my syncing script for Google Classroom. I have started rewriting my script from the ground up around a new Sync-GSCourse helper fucntion that I want to propose.

The idea is that the function would take an object representing a course and it's participants as input and then do the heavy lifting for you. It would retrieve/check the current values in Google Classroom and then call the New-GSCourse, Update-GSCourse, 'Add-GSCourseParticipant', etc functions for you as required to ensure that Google Classroom matches the input objects.

My use case is that I sync Google Classroom regularly with data from our timetabling software and I currently have ~350 courses completely automated. Students/teachers added/removed as required and courses created when required. Given the large number of courses it is not feasible to retrieve the course and it's participants from Google Classroom each time you call the Sync-GSCourse as this takes time extending the script runtime but it also consumes requests against the API quota. So I am aiming to include caching functionality to allow saving/loading the course details to local disk as a simple CSV file.

I have started creating that function here as a proof of concept: https://github.com/Foggy2/PSGSuite/blob/sync-gscourse/PSGSuite/Public/Classroom/Sync-GSCourse.ps1

It still needs quite a bit of work at this stage as I only have rough code at this stage but before I continue any further with writing and testing it I just wanted to throw the idea out there and see how it would be received? Is this something that would be acceptable for inclusion in the module?

I am most definitely not a developer and have no formal programming training. This is an out of hours hobby project for me to use to keep me interested in learning PowerShell. So with that in mind I am also interested in feedback on the approach I have taken. Any constructive feedback would be welcomed.

Foggy2 commented 3 years ago

As I will be using it myself regardless if it is added to the module I have continued to work on this while I have had some time. I have polished it up a bit, included some examples and done some testing. So far all seems to work quite well but like I said previously I am self taught with PowerShell so please don't be afraid to point out any issues or suggestions. I am still learning. :)