I recommend creating an Intune config profile to sync a Library to Onedrive. Once the policy is created, use the generated values in this script. It works, percentage signs and all.
The only thing the config policy does not generate is the site name. Get the site name from the SharePoint admin page.