Estimated Reading Time: 3 minutes
Azure Runbooks are part of Azure process automation. Today I will show you how we can create a runbook in the azure portal. First we will check how we can create a run book, in the first step we will search for Automation from Azure Market Place.
The next step is to create an azure automation account
The next step is add an azure automation account and store the credential.
In the next step you need to create the Credential
Once it’s created you can find your automation account.
That’s all you are set.
Now I will like to create a runbook which will give me the list of GlobalAdmin user’s in the O365 tenant at my organization.
So I need to import the office 365 PowerShell module. As you can find below.
Import MSOnline PowerShell Module.
Click on Browse gallery.
Browse the MSOnline Module
Now you need to create the Runbook, go to the Automation Account. In my case the Automation Account Name is RoboMan1
Go to the process Automation and click on Runbook
Click on Add a Runbook
Click on Create a new Runbook
Now click on Edit the PowerShell Script and enter the below script
$credObject = Get-AutomationPSCredential -Name “Master_Global_Admin”
Connect-MsolService -Credential $credObject
$role = Get-MsolRole -RoleName “Company Administrator”
$output=Get-MsolRoleMember -RoleObjectId $role.ObjectId
$Display=$output | Select-Object DisplayName,EmailAddress
Now you can publish the run book, to start the runbook go the runbook name and double click it as shown below
Click on the start button to start the run book, once the job is started you can see the following.
If you click on the output tab you can find the output of the runbook which has just ran.
The log window will show the logs of the last ran runbooks details as shown below
The error window will list any error which occur during the execution.
So with Azure Runbooks you can manage all your o365 admin tasks and more. The Runbook credential manager will store the credential and it’s very secure because even developer’s also unable to view the credential if he/she don’t have the correct permissions.
I hope you will like this post, I will come more with Azure Runbooks in my future posts. Thanks.