> For the complete documentation index, see [llms.txt](https://docs.smsagent.blog/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.smsagent.blog/microsoft-endpoint-manager-reporting/intune-assignments-report/create-an-azure-automation-runbook.md).

# Create an Azure automation runbook

## PowerShell Modules

A couple of PowerShell modules are needed. If you are using the latest PowerShell runtime environment (7.2 at the time of writing), these modules should already be present and there should be no reason to create your own runtime environment. If you are using your own runtime environment, make sure the following modules are present and up-to-date.

* **Az.Accounts**
* **Az.Storage**

## Prepare the Runbook

Download the automation runbook script from here: <https://github.com/SMSAgentSoftware/IntuneAssignmentsReport/blob/main/Export-MSIntuneAssignments.ps1>

In the **Variables** section near the top of the script, set values for the following variables:

* **ResourceGroup**. The name of the Resource group that hosts the Azure storage account.
* **StorageAccount**. The name of the Storage account.
* **Container**. The name of the container you created.

## Create a Runbook

* Click on the **Runbooks** pane and choose **Create a runbook.**
* Choose **Browse for file** and select the runbook script you downloaded.
* Select the latest **runtime environment** (eg 7.2 at time of writing).
* Click **Review + Create**.
* When ready, **Publish** the runbook.

<figure><img src="/files/ExEC09rhZIuEE9n6pCIC" alt=""><figcaption></figcaption></figure>

## Schedule the Runbook

Schedule the Runbook to execute at regular intervals to keep the data updated, every 3 hours for example.

* In the Azure portal, in the automation account, open the Runbook you created
* Click **Link to schedule**
* In the **Schedule** section, select an existing schedule or create a new one

![](/files/-M_SHJw26sAMuYhaSEaI)
