SharePoint Online Jobs On Azure Runbook Using PowerShell Scripts - Part Two

Introduction

In this article, you will learn, how to add SharePoint online credentials and create schedules on Azure Runbook.

This article is the second part of an articles series which helps in creating Azure Runbook to create schedules for SharePoint online.

In my previous article, I explained the prerequisites like creating an automation and importing SharePoint online assemblies references to the portal.

The components, given below, are explained in detail here-

  • Adding SharePoint online Credentials.
  • Creating Runbook with the necessary script.
  • Testing the script.

Add credentials

Azure Runbook will run the code at the scheduled run time. For this, we require the credentials to be stored on Azure automation portal.

  1. From our automation component, click assets. Click credentials.

    assets

  2. Click "add a credential" button. Provide SharePoint online portal tenant admin credentials, which will be used to run the schedules on Azure Runbook. Click create. The credentials will be saved to the portal.

    credential

  3. The following snapshot shows the stored credentials.

    credentials

Create Runbook

Runbook on Azure helps-

  • Writing the necessary automation scripts.
  • Run the scripts, based on the schedules.
  • View the results of the schedules.
  1. From the automation component, click Runbook under resources. Runbook lists down all the default published Runbooks, available for the automation.

    automation

  2. Click "Add a runbook". Click Quick create.

    Add a runbook

  3. Create Runbook with the Runbook name and type. Since in this example, we are going to run PowerShell scripts for an automation, we will select Runbook and type as PowerShell. Click create.

    runbook

  4. Once created, the portal will show the screen, given below, with the script editors to add SharePoint script commands.

    SharePoint script commands

  5. The imported SharePoint online cmdlets can be seen under cmdlets section of Runbook. The snapshot, given below, shows the same-

    cmdlets section

  6. In Runbook code editor, write the necessary PowerShell script. In my example, I have written the code snippet to retrieve the available sites.

    editor

  7. To test the code snippet, save the code by clicking "save" and click "test pane" button available over the code editor. The test pane will open along with the console.

    save

  8. From the test pane, click Start and wait for Runbook to complete the operations.

    Start

Summary

From this article, you have learned how to add SharePoint online credentials for an automation. Create Runbook and add the necessary script. Also, you have seen testing the written script.

In my next article, you will learn, how to run the scripts on the schedule time.

Up Next
    Ebook Download
    View all
    Learn
    View all