简体   繁体   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: 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

I am getting 'access denied':我收到“拒绝访问”:

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

I'm probably doing something wrong or didn't make the proper settings.我可能做错了什么或没有进行正确的设置。 Can you please help me?你能帮我么? Thanks in advance.提前致谢。

looks like you connect fine, but not allowed to upload, so looks like permission issues on your app creation, make sure to go to https://mydomain.sharepoint.com/_layouts/15/appinv.aspx (if you want to upload to main site, normally you would want to upload to sub sites, but just using your example) On that page type the “Client ID” that you got when you created the app into the “App ID” field and then click the “Lookup” button Add the following into Permission Request XML:看起来你连接正常,但不允许上传,所以看起来你的应用程序创建权限问题,请确保 go 到https://mydomain.Z2D60FC67EF31D40B76705037DA990/iflayouts/5到上传到主站点,通常您希望上传到子站点,但仅使用您的示例)在该页面上,将创建应用程序时获得的“客户端 ID”键入“应用程序 ID”字段,然后单击“查找” 按钮 在权限请求 XML 中添加以下内容: 应用程序 Then click create at the bottom Click "Trust It" to set permissions and try again然后点击底部的创建点击“信任”设置权限再试一次

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用PowerShell使用元数据将文件上载到SharePoint Online - Upload file to SharePoint Online with metadata using PowerShell 如何使用 Powershell CSOM 将用户添加到 sharepoint 在线站点? - How to add a user to sharepoint online site using Powershell CSOM? 使用 Powershell 将文件上传到 Sharepoint Online (Microsoft 365)(选项 2 - 使用 Microsoft.SharePoint.PowerShell) - Upload file to Sharepoint Online (Microsoft 365) using Powershell (Option 2 - Using Microsoft.SharePoint.PowerShell) 删除 SharePoint 在线站点 collections 使用 powershell - Delete SharePoint Online site collections using powershell 使用 Powershell 将文件上传到 Sharepoint Online (Microsoft 365)(选项 4 - 使用 Microsoft.SharePoint.Client.ClientContext) - Upload file to Sharepoint Online (Microsoft 365) using Powershell (Option 4 - Using Microsoft.SharePoint.Client.ClientContext) 使用 Powershell(选项 1 - 使用 PnP.Powershell)将文件上传到 Sharepoint Online (Microsoft 365) - Upload file to Sharepoint Online (Microsoft 365) using Powershell (Option 1-Using PnP.Powershell) 使用Powershell将文件上传到SharePoint - Upload file to SharePoint using Powershell 使用 PowerShell 脚本和 CSOM 在 SharePoint Online 中设置网站徽标 - Set Site logo in SharePoint Online using PowerShell Script and CSOM 如何使用 PowerShell 在 SharePoint 上在线向所有站点 collections 报告用户权限 - How get users permissions report to all site collections on SharePoint Online using PowerShell 使用Powershell将多个文件从多个文件夹上载到SharePoint Online - Upload multiple files from multiple folders to SharePoint online using Powershell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM