Javier M
Javier M

Reputation: 23

azure runbook get who executed the job

I was working with azure runbooks in automation accounts for quite a while but recently I was tasked to identify who was executing the runbook.

I noticed that there is a fied called "Executed by" when you get information from a job, but seems that field is being removed by MSFT.

Checking the logs I can see the calls to the runbook but the job id stated in the log doesn't match the one in the jobid in the runbook inside the automation account.

I was wondering how can I match an execution on a runbook with a entry in the log.

any idea with powershell or by calling the REST API directly?

Thanks!

Upvotes: 1

Views: 1277

Answers (1)

4c74356b41
4c74356b41

Reputation: 72176

You can get the user who started the Automation job using the startedBy field returned in the Get-AzureRmAutomationJob and REST API.

This will require passing in the job id, which you can get using: $PsPrivateMetadata.JobId.Guid

Upvotes: 2

Related Questions