使用SharePoint PNP将文件上载到Sharepoint库 [英] Upload files to Sharepoint library using SharePoint PNP

查看:161
本文介绍了使用SharePoint PNP将文件上载到Sharepoint库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Guys, 


我们的在线sharepoint启用了MFA。因此,我们使用系统帐户上传文件的脚本已被阻止。为此,我已注册应用程序并提供对共享点文档库的应用程序的访问权限。我可以使用app将
连接到sharepoint,但是当我尝试使用add-pnpfile和ty上传文件时,我收到访问被拒绝 


这是我的命令



PS C:\windows \\ \\system32>连接-pnponline -url https://abc.sharepoint.com/teams/ITSSQL -AppId< ID>&NBSP; -AppSecret< appSECRET>

PS C:\windows\system32> Add-PnPFile -path c:\ html \ labs.txt -folder" Shared documents"

Add-PnPFile:拒绝访问。您无权执行此操作或访问此资源。

在行:1 char:1

+ Add-PnPFile -path c:\ html \ labs.txt -folder"共享文件"

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
  &NBSP; + CategoryInfo  &NBSP; &NBSP; &NBSP; &NBSP; :WriteError:(:) [Add-PnPFile],ServerUnauthorizedAccessException

  &NBSP; + FullyQualifiedErrorId:异常,SharePointPnP.PowerShell.Commands.Files.AddFile


C:\html\labs.txt是我的电脑stirage位置,其中i是上传文件









解决方案

嗨Kundan Ghimire,


如果你启用了MFA,它会对授予应用程序的权限产生影响。


你可以暂时禁用MFA ,然后检查是否会发生同样的问题。


更多参考:


使用应用程序上下文访问SharePoint,也称为仅限应用程序。


'p> https://docs.microsoft.com/en-我们/ sharepoint / dev / solution-guidance / security-apponly-azureacs


祝你好运,


Sara Fan


Hello Guys, 

We have sharepoint online which have MFA enabled. Due to this our Scripts to upload files using system accounts has been blocked. For this purpose I have register app and provided access to the app to the share point document library . I am able to connect to sharepoint online using app however when I tried to use add-pnpfile and ty to upload the file i receive access denied 

Here is my commands

PS C:\windows\system32> connect-pnponline -url https://abc.sharepoint.com/teams/ITSSQL -AppId <ID> -AppSecret<appSECRET>
PS C:\windows\system32> Add-PnPFile -path c:\html\labs.txt -folder "Shared documents"
Add-PnPFile : Access denied. You do not have permission to perform this action or access this resource.
At line:1 char:1
+ Add-PnPFile -path c:\html\labs.txt -folder "Shared documents"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [Add-PnPFile], ServerUnauthorizedAccessException
    + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Files.AddFile

c:\html\labs.txt is my pc stirage location where i am uploading files


解决方案

Hi Kundan Ghimire,

If you enable the MFA, it will have an impact of granting permission for the App.

You could disable the MFA temporarily, then check if the same issue will occur.

More reference:

Accessing SharePoint using an application context, also known as app-only.

https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs

Best regards,

Sara Fan


这篇关于使用SharePoint PNP将文件上载到Sharepoint库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆