Automap Sharepoint Libraries to OneDrive

Job ID: 33172884

Budget: £750 – £1,500 GBP

When a new user logs onto a PC, their OneDrive is automatically logged in and started (using an InTune policy). I would like to create a script that does the following after login:

a) Checks OneDrive is running and waits then checks again after 30 seconds if not running (repeat 3 times before displaying error message)
b) Uses the logged on AAD profile to query Office 365 and find out which Groups the user has been added to
c) Checks the returned list of groups against a list of known groups with Document Library shares
d) Where matched, adds the Sharepoint library(ies) to the OneDrive client
e) Adds some sort of flag to stop trying to add libraries if they are already mapped in OneDrive

ADDITIONAL INFO
There may be a better way but I've only found the following script which adds libraries .. it may help:

param(
[String]$siteid = ".............",
[String]$webid = "...........",
[String]$listid = "...........",
[String]$URL = "https%3A%2F%2F..........",
[String]$webtitle = "Site Title",
[String]$listtitle = "Documents"
)

start "odopen://sync/?siteId=$siteid&webId=$webid&listId=$listid&userEmail='InsertUsernameHere'&webUrl=$URL&webtitle=$webtitle&listtitle=$listtitle"

If it helps I can provide a list of WebID / ListID / SiteID for all known libraries to use as a reference point.
All machines running Windows 10 Pro.

Thank you.
Related categories: Windows Desktop Sharepoint Azure Powershell Office 365