为什么 PnP PowerShell 命令在 WindowsPowerShell ISE 中不起作用?

问题描述 投票:0回答:1

在这里,我需要使用 PnP PowerShell cmdlet 签出 SharePoint 文档库中的文件。当我在 Windows powershell ISE 上执行此脚本时。

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

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

然后我收到以下错误。
Plese provide solution to this error

但是相同的脚本可以在 PowerShell7 上运行。

我期待如何在 Windows powershell ISE 上运行这些 pnp 命令。

powershell sharepoint-online
1个回答
0
投票

PnP.PowerShell 的最新版本通道 (2.x) 至少依赖于 .NET 6,这就是它无法在 Windows PowerShell 或 ISE 中加载的原因。

来自 GitHub 项目自述文件

重要信息 - 新的 PnP PowerShell 2.x

随着 PowerShell 背后的技术不断发展,PnP PowerShell 模块也会不断发展。自 2022 年 12 月起,Microsoft 不再支持 .NET 3.1,并且 .NET Framework 也不再积极开发。它也不是跨平台的。 PnP PowerShell 2.x 因此将不再支持 PowerShell 5.1 或 ISE

您可以通过在安装模块时显式指定版本来安装可在 Windows PowerShell 中运行的先前版本:

Install-Module PnP.PowerShell -RequiredVersion 1.12.0 -Force

尽管我个人建议用 Visual Studio Code 替换 PowerShell ISE - 这样您就可以从开发环境访问和使用最新版本

© www.soinside.com 2019 - 2024. All rights reserved.