import-pnponline error in azure automation runbook

Adri 0 Reputation points
2025-05-13T10:46:12.0066667+00:00

Hi,

I am new with Azure automations.

I have created one runbook in an azure automation account. The runbook is using PowerShell 7.2.

I have added the pnp module from the "Browse Gallery". Set it for PowerShell 7.2.

When running a simple import-pnponline command I get the following error:

"The version of PowerShell on this computer is '7.2.0'. The module 'C:\usr\src\PSModules\PnP.PowerShell\PnP.PowerShell.psd1' requires a minimum PowerShell version of '7.4.6' to run. Verify that you have the minimum required version of PowerShell installed, and then try again."

Why is this module in the library if can not be used in Azure automation?

How do I get around this?#

Thanks,

Adrian

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
{count} votes

1 answer

Sort by: Most helpful
  1. Arto Collumbien 10 Reputation points
    2025-07-28T13:36:25.3066667+00:00

    Hello Adri,

    I just got the same problem and found a workaround that will probably work for you too:

    1. Go to the runtime environment you are using
    2. Delete the PnP.PowerShell module that is giving you the issue (3.1 I assume) and hit save
    3. Go to the PowerShell Gallery to the page of the latest working module version (in your case 2.12): https://www.powershellgallery.com/packages/PnP.PowerShell/2.12.0
    4. In install options you can choose to manually download this version
      User's image
    5. Go to your download location and rename the .nupkg file to "PnP.PowerShell.zip"
    6. Go back to your runtime environment and choose "+ Add a file"
    7. Choose your zip, hit save and wait a few minutes for the status to change from "Importing" to "Available"

    After this you can Import the module using Import-module PnP.PowerShell in your runbook and not get any error messages about a version mismatch.

    Hope this is still helpful to you or others...

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.