簡體   English   中英

無法在 VSCode 中使用 SharePoint PNP PowerShell

[英]Unable to Use SharePoint PNP PowerShell in VSCode

在 VScode 中運行此命令不起作用,但它在 PowerShellPlus 中有效。

Connect-PnPOnline -Url "https://something.sharepoint.com/" -Credentials $userCredential

錯誤:

   System.MissingMethodException: Method not found: 'System.Runtime.Remoting.ObjectHandle System.Activator.CreateInstance(System.String, System.String)'.
   at SharePointPnP.PowerShell.Commands.Base.ConnectOnline.ProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()

我已經嘗試卸載 VScode 並刪除我的機器上的任何 SharePoint 痕跡,但我無法克服此錯誤。 有任何想法嗎?

編輯:在這篇博文之后,我刪除並重新安裝了 SP PNP 模塊。https://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=802

  1. 從控制面板中刪除所有 SharePoint 組件(添加/刪除)
  2. 打開 GAC 位置 (C:\\windows\\Microsoft.NET\\assembly\\GAC_MSIL),搜索術語 SharePoint 並刪除所有文件夾。 (這是必需的,因為 PnP 命令使用的參考仍然是舊的)
  3. 重新啟動機器
  4. 安裝最新版本的 SharePoint PnP

這是我解決問題的方法:
1. 在 VSCode 中,使用 Ctrl+Shift+P 打開 Windows 或 Linux 上的命令面板。 在 macOS 上,使用 Cmd+Shift+P。
2. 搜索會話。
3. 單擊 PowerShell:顯示會話菜單。
4. 選擇___ (x86)選項之一

我使用的是 x64,這顯然不起作用。

請不要在您的機器中 uninatll 的 SharePoint 跟蹤,並確保您已安裝相應的 PnP PowerShell 庫:

SharePoint/PnP-PowerShell

然后在 VSCode 中,請安裝 PowerShell 插件:

在此處輸入圖片說明

打開保存 PnP PowerShell 代碼的 .ps1 並按 F5 運行和調試:

在此處輸入圖片說明 在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM