Azure Automation Run As Account will retire on September 30, 2023 and will be replaced with Managed Identities. Before that date, you’ll need to migrate your runbooks to use managed identities.

However, just the presence of a Run As account doesn’t mean a it is being used. Often these were just created during the automation account provisioning. This script help to determine if you are using the Run As account by search through the runbooks to find references to the Run As Account actually being called. Then finds the last time the runbook was executed. If no date is returned, then the runbook has not executed in the last 30 days.