powershell – Restore SQL databases with a custom AzureRM script extension

I'm trying to download and restore database backups against a SQL server with a custom AzureRM script extension. The files download is fine, but restores fail and access is denied (for database master). I'm assuming that the script runs as a local system account and has no permissions.

For many other activities that I perform as part of Azure automation, I can pass a credential object to process this material without storing secrets (for example, the result of a get-credential passed as an argument). However, Set-AzureRmCustomScriptExtension leaves only arguments of type "string"

How can I set the command line command restore-sqldatabasebackup in this custom script extension to use the existing user who is authorized to do so?