'Connect-PnPOnline' not recognized as a name of a cmdlet when running from Azure Runbook #4880
-
Ok, I'm newbie with Azure Runbooks, but didn't think I will face problems this early. :D So I'm trying to run PnP Powershell script to fetch user profile attributes from EntraID profiles and write them to SharePoint user profiles and schedule it to run weekly. I have imported PnP PowerShell module (module version 3.1.0, runtime version 7.2.) to the Azure Automation account (and I can see it when browsing the imported modules) and assigned permissions to SharePoint to the Managed Identity like this:
However when I'm testing my script I get this: Connect-PnPOnline -URL https://xxx.sharepoint.com/ -ManagedIdentity Then I tried to add Import-Module PnP.PowerShell before the Connect-PnPOnline cmdlet and I get this: However if run Install-Module -Name PnP.PowerShell before the Connect-PnPOnline cmdlet I don't get those errors, but surely I'm not supposed to install module everytime I run the script. So two questions:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
In a potential application of Cunningham's Law |
Beta Was this translation helpful? Give feedback.
Thanks, but eventually I managed to get it working by creating Runtime Environment with PowerShell 7.4 and imported PnP PowerShell 2.12 module in it.
PnP PowerShell 3.x requires PowerShell 7.4.6 and Azure Automation doesn’t support that yet.