Why PnP PowerShell commands are not working inWindowsPowerShell ISE?

54 Views Asked by At

Here, I need to checkout a file in SharePoint document library using PnP PowerShell cmdlets. when i'm executing this script on windows powershell ISE.

Connect-PnPOnline -Url https://szg52.sharepoint.com/sites/SalesDepartmentTeam -Credentials (Get-Credential)

Set-PnPFileCheckedOut -Url "/CompanyBasicInformation/Company%20Info.pdf"

Then Im getting this below error.
Plese provide solution to this error

But the same script is working on PowerShell7.

Im expecting how to run these pnp commands on windows powershell ISE.

1

There are 1 best solutions below

1
Mathias R. Jessen On

The latest release channel (2.x) of PnP.PowerShell depends on at least .NET 6, which is why it can't be loaded in Windows PowerShell or ISE.

From the GitHub project README:

IMPORTANT - New PnP PowerShell 2.x

As the technologies behind PowerShell evolve, so will the PnP PowerShell module. Microsoft is no longer supporting .NET 3.1 since December 2022, and .NET Framework is not actively being developed anymore. It is also not cross platform. PnP PowerShell 2.x will therefore no longer support PowerShell 5.1 nor the ISE.

You can install a previous version that works in Windows PowerShell by explicitly specifying the version when installing the module:

Install-Module PnP.PowerShell -RequiredVersion 1.12.0 -Force

Although I'd personally suggest replacing PowerShell ISE with Visual Studio Code - that way you'll be able to access and use the latest version from your development environment