Я хочу экспортировать веб-часть XML на основе GUID в локальный. Я пытаюсь выполнить экспорт из SharePoint 2013 с помощью CSOM PowerShell. Кто-нибудь предлагает по этому поводу?
function EnsureDirectory($exportFolderPath)
{
if ( -not (Test-Path $exportFolderPath) ) {New-Item $exportFolderPath -Type Directory | Out-Null}
}
function ExportAllWebParts()
{
$WebURL= ""
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($WebURL)
$Page = $ctx.web.GetFileByServerRelativeUrl("")
$ctx.Load($Page)
$ctx.ExecuteQuery()
$wpManager = $Page.GetLimitedWebPartManager([Microsoft.SharePoint.Client.WebParts.PersonalizationScope]::Shared)
$webparts = $wpManager.Webparts
$ctx.Load($webparts)
$ctx.ExecuteQuery()
if($webparts.Count -gt 0){
Write-Host "Looping through all webparts"
foreach($webpart in $webparts){
$exportPath = "" + "\" + $webpart.Title + ".xml"
$xwTmp = new-object System.Xml.XmlTextWriter($exportPath,$null);
$xwTmp.Formatting = 1;#Indent
$wpManager.ExportWebPart($webpart, $xwTmp);
$xwTmp.Flush();
$xwTmp.Close();
#$webpartXmlWriter = New-Object System.Xml.XmlTextWriter($fileName,$null)
#$webpartXmlWriter.Formatting = [System.Xml.Formatting]::Indented
#$wpManager.ExportWebPart($webpart,$webpartXmlWriter)
}
}
}
ExportAllWebParts