Hi Cossy Cosmas,
Thank you for confirming. You don't require a script, these scheduled tasks utilize Azure Logic Apps or Azure Automation to execute the action. This means that authentication is still necessary, likely occurring through your Azure account credentials or a service principal established during the task setup.
Check the role assignments in Azure portal: VM > Access control (IAM) > Role assignments
See that you have Contributor role or Virtual Machine Contributor role.
Recreate the Task with Proper Permissions: Delete the existing task from the VM > Automation > Tasks blade.
Recreate the task using your own account, which is the recommended way, or A service account with Owner or Contributor rights. Ensure the identity creating the task has at least the Virtual Machine Contributor role.
Check Microsoft.Compute Resource provider: Go to Subscriptions → Your subscription → Resource providers. Ensure Microsoft.Compute is registered. If not, click "Register"
If you have any further queries, let me know. If the information is helpful, please click on Upvote.