簡體   English   中英

如何使用 PowerShell 在線將文件上傳到 SharePoint 中的中心站點

[英]How to upload a file to a hub site in SharePoint Online using PowerShell

I've created a new app, generated app id and secret, assigned full permissions for https://mydomain.sharepoint.com but I can't upload a file to the Shared Documents folder using the following PowerShell commands:

$SharePointURL = "https://mydomain.sharepoint.com"
$SharePointDestPath = "/Shared Documents"
$file = "some-file"

Connect-PnPOnline -Url $SharePointURL -ClientId "asddsf-9999-4a88-8c79-ab8cabc67889" -ClientSecret "123343sdsfsdgfg2343434345656=" -WarningAction Ignore
Write-Host "done"
Write-Host "Uploading output file ... " -NoNewline
Add-PnPFile -Path $file -Folder $SharePointDestPath
Disconnect-PnPOnline

我收到“拒絕訪問”:

PS E:\sharepoint_online> .\script.ps1
Connecting to SharePoint online ... done
Uploading output file ... Add-PnPFile : Access denied.
At E:\sharepoint_online\script.ps1:26 char:1
+ Add-PnPFile -Path $file -Folder $SharePointDestPath -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Add-PnPFile], ServerUnauthorizedAccessException
+ FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Files.AddFile

我可能做錯了什么或沒有進行正確的設置。 你能幫我么? 提前致謝。

看起來你連接正常,但不允許上傳,所以看起來你的應用程序創建權限問題,請確保 go 到https://mydomain.Z2D60FC67EF31D40B76705037DA990/iflayouts/5到上傳到主站點,通常您希望上傳到子站點,但僅使用您的示例)在該頁面上,將創建應用程序時獲得的“客戶端 ID”鍵入“應用程序 ID”字段,然后單擊“查找” 按鈕 在權限請求 XML 中添加以下內容: 應用程序 然后點擊底部的創建點擊“信任”設置權限再試一次

暫無
暫無

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

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