The latest pnp.powershell module (V2.X and above) now won’t work with PowerShell v5. Thus, I have updated my PnP connection script:
https://github.com/directorcia/Office365/blob/master/o365-connect-pnp.ps1
to accommodate this.
Thus, if you attempt to run this script in PowerShell version 5 with the latest pnp.powershell module you will typically see:
and the error is:
Could not load file or assembly ‘System.Management.Automation, Version=7.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The system cannot find the file specified.
However, when you run the script in PowerShell V7 you’ll see:
that the connection is successful.
I have also taken the opportunity to remove the dependency in the script as well on the now depreciated module MSONLINE and replaced it the Microsoft.Graph module.
This kind of signals the beginning of the end for modern cloud modules in PowerShell 5. However, some still require PowerShell 5 but I expect that to change.
In summary, the latest pnp.powershell modules require PowerShell version 7 and I have updated my connection script to accommodate this.