[英]powershell returned an error:(403) WebException using New-pnpList
I had my PS script running the other day and created a new list with a single field with no issues.前几天我运行了我的 PS 脚本并创建了一个新列表,其中包含一个没有问题的字段。 Was able to view the list in the Site Contents lib.
能够查看站点内容库中的列表。
Today, it's not working.今天,它不工作了。 I tried running the PS code below and then resorted to running the new-pnplist code at the command line...got the same error which is shown below.
我尝试运行下面的 PS 代码,然后求助于在命令行运行 new-pnplist 代码......得到了相同的错误,如下所示。
I'm using the Global admin account.我正在使用全局管理员帐户。 Using version 3.13.19 SharePointPNPPowerShellOnline.
使用版本 3.13.19 SharePointPNPPowerShellOnline。 Executed the commands from Powershell ISE which is what I did the other day when it worked.
执行来自 Powershell ISE 的命令,这是我前几天工作时所做的。 And, I was able to connect successfully using the Connect-sposervice command.
而且,我能够使用 Connect-sposervice 命令成功连接。
Error:错误:
new-pnplist -Template GenericList -Title 'TestPNP2'
new-pnplist : The remote server returned an error: (403) Forbidden.
At line:1 char:1
+ new-pnplist -Template GenericList -Title $ListName
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [New-PnPList], WebException
+ FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Lists.NewList
Code:代码:
$TargetListURL="https://<my sharepoint.com>/sites/CKCDemo"
$ListName="TESTPNP2"
Connect-PnPOnline -url $TargetListURL -CurrentCredentials
New-PnPList -Template GenericList -Title $ListName
Add-PnPField -List $ListName -DisplayName "MyTEST" -InternalName "MyTEST" -Type Text -AddToDefaultView
Get-PnPList`
Make sure you have enough permission to create a list in this site.确保您有足够的权限在此站点中创建列表。 You could try to go to the site directly, check whether you could create a list through ui.
你可以尝试go 直接到站点,检查是否可以通过ui创建列表。
Note: A global admin will not automatically have access to individual sites unless explicitly granted.注意:除非明确授予,否则全局管理员不会自动访问各个站点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.