Finding Azure Automation accounts with RunAs accounts

A colleague sent this Microsoft notification around about RunAs accounts retiring later this year. I don’t use them (having switched to Managed Identities a while ago) but I was curious if anyone else is using these.

Came up with this bit of PowerShell to find such accounts.

I found a bunch of results in our case but turns out even though they had the RunAs account it wasn’t actually in use (the certs had expired a long time ago, for instance). Wonder if there’s some way of also getting the RunAs certificate and checking it’s date… though I can’t be bothered with it. :)