Я пытаюсь создать веб-части sharepoint, используя powershell. Но каждый раз, когда я что-то загружаю (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."