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.
- Search for and select Automation Accounts.
- On the Automation Accounts page, select your Automation account from the list.
- From your Automation account, under Shared Resources, select Modules.
- Select Add a module. In the Add a module page, you can select either of the following options:
- Browse for file - select a file from your local machine.
- Browse from Gallery - you can browse and select an existing module from the gallery.
- Click Select to select a module.
- Select the Runtime version and click Import.
Once it is installed, it will be visible in available modules,
You can run any PNP Script now. It will work without any errors.