尝试向SharePoint Online网站添加功能时出现System.Xml.XmlException

时间:2018-07-13 18:15:02

标签: powershell sharepoint sharepoint-online

我试图通过模型创建站点,并得到警告说该模型使用了某些禁用的功能(“ GlobalHold功能”和“ MobileExcelWebAccess功能”)。显然,这些功能已被弃用,因为它们未显示在Sharepoint配置界面中,因此我尝试了以下Powershell脚本(我在Microsoft论坛帖子中读到,仍然可以通过SharePoint SDK启用这些已弃用的功能)

try

{

Add-Type -Path # path to Microsoft.Online.SharePoint.Client.Tenant.dll

Add-Type -Path # path to Microsoft.SharePoint.Client.Runtime.dll

$siteUrl = #...

$username = #...

$password = #...

$securePassword = convertto-securestring $password -asplaintext -force

$spoCtx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)

$spoCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $securePassword)

$spoCtx.Credentials = $spoCredentials

$featureGuid = [System.Guid]"2a6bf8e8-10b5-42f2-9d3e-267dfb0de8d4"

$spoSite=$spoCtx.site

$spoSite.Features.Add($featureGuid, $true, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None)

$spoCtx.ExecuteQuery()

$spoCtx.Dispose()

}

catch [System.Exception]

{

write-host -f red $_.Exception.ToString()

}

尽管如此,我还是得到了以下异常:

System.Xml.XmlException: //exception message
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.ParseDoctypeDecl()
   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
   at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
   at Microsoft.SharePoint.Client.Idcrl.IdcrlAuth.DoGet(String url)
   at Microsoft.SharePoint.Client.Idcrl.IdcrlAuth.RequestFederationProviderInfo(String domainname)
   at Microsoft.SharePoint.Client.Idcrl.IdcrlAuth.GetFederationProviderInfo(String domainname)
   at Microsoft.SharePoint.Client.Idcrl.IdcrlAuth.InitFederationProviderInfoForUser(String username)
   at Microsoft.SharePoint.Client.Idcrl.IdcrlAuth.GetServiceToken(String username, String password, String serviceTarget, String servi
cePolicy)
   at Microsoft.SharePoint.Client.Idcrl.SharePointOnlineAuthenticationProvider.GetAuthenticationCookie(Uri url, String username, Secur
eString password, Boolean alwaysThrowOnFailure, EventHandler`1 executingWebRequest)
   at Microsoft.SharePoint.Client.SharePointOnlineCredentials.GetAuthenticationCookie(Uri url, Boolean refresh, Boolean alwaysThrowOnF
ailure)
   at Microsoft.SharePoint.Client.ClientRuntimeContext.SetupRequestCredential(ClientRuntimeContext context, HttpWebRequest request)
   at Microsoft.SharePoint.Client.SPWebRequestExecutor.GetRequestStream()
   at Microsoft.SharePoint.Client.ClientContext.GetFormDigestInfoPrivate()
   at Microsoft.SharePoint.Client.ClientContext.EnsureFormDigest()
   at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
   at CallSite.Target(Closure , CallSite , Object )

该异常消息不是英语的,但实际上表示“出于安全原因,此XML文档中禁止使用DTD。要启用DTD处理,请将XmlReaderSettings中的DtdProcessing定义为Parse,然后将这些配置传递给方法XmlReader.Create”。

所有这些XML内容可能都是在SharePoint SDK的基础实现中完成的,因此我不确定如何从此处继续。有什么想法吗?

0 个答案:

没有答案
相关问题