Install PNP Powershell Module In Azure Runbook Environment

Execute PNP Scripts in Azure Runbook

You might encounter many issues when you work with Azure runbooks for the first time. One of the issues is how to execute PNP Scripts inside Runbook PowerShell commands. Well, the answer is straightforward, you need to Install PNP PowerShell Module in your Azure Automation Account.

If the PNP PowerShell module has not been installed on your Azure automation account then you will get the error below,

"Connect-PnPOnline: The term 'Connect-PnPOnline' is not recognized as the name of a cmdlet, function, script file, or operable program".

Installing PnP PowerShell into Azure Automation Accounts

All we have to do is find the Module option in the left hand navigation.

Sign in to the Azure portal.

  1. Search for and select Automation Accounts.
  2. On the Automation Accounts page, select your Automation account from the list.
  3. From your Automation account, under Shared Resources, select Modules.
  4. Select Add a module. In the Add a module page, you can select either of the following options:
    1. Browse for file - select a file from your local machine.
    2. Browse from Gallery - you can browse and select an existing module from the gallery.
  5. Click Select to select a module.
  6. Select the Runtime version and click Import.

Install PNP Powershell Module in Azure Runbook environment

Install PNP Powershell Module in Azure Runbook environment

Install PNP Powershell Module in Azure Runbook environment

Once it is installed, it will be visible in available modules,

Install PNP Powershell Module in Azure Runbook environment

You can run any PNP Script now. It will work without any errors.