# 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)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.smsagent.blog/microsoft-endpoint-manager-reporting/intune-assignments-report/create-an-azure-automation-runbook.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
