【发布时间】:2019-08-30 11:20:03
【问题描述】:
我正在尝试使用 powershell 创建共享点 webpart。但是每次我加载 (Context.Load()) 东西时,我都会遇到错误。
这是我的代码。
[Reflection.Assembly]::LoadFile(([System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client").location))
[Reflection.Assembly]::LoadFile(([System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.runtime").location))
$tenantAdmin = "#####@ajoncloud.onmicrosoft.com"
$tenantAdminPassword = "#########"
$secureAdminPassword = $(convertto-securestring $tenantAdminPassword -asplaintext -force)
$siteURL = "https://ajoncloud.sharepoint.com/LND"
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($tenantAdmin,$secureAdminPassword)
$ctx.Credentials = $credentials
这部分工作得很好。但是如果我尝试以下语句,我会得到错误。
$web = $ctx.Web
$ctx.Load($web)
$ctx.ExecuteQuery()
这是我遇到的错误。
Exception calling "ExecuteQuery" with "0" argument(s): "The remote server returned an error: (403) Forbidden."
【问题讨论】:
标签: asp.net powershell sharepoint csom