Archive

Posts Tagged ‘target’

SharePoint 2013: Identifying the variation source and target with PowerShell

While working with one reporting requirement I needed to eliminate the variation targets and only need to consider variation sources. I struggled to find out the property which will help me to identify the page is variation source or target.

Solution:

Publishing web and Publishing page have the property called as ‘PublishingPage.Label.IsSource’ which we can use to identify the source page and source web. The same way we can use the publishing web level property as well.

if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($childWeb)){
 $spPubWeb =
 [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($childWeb);

 $item = $spPubWeb.PagesList.GetItemById($row.ID);
 $pubPage =
 [Microsoft.SharePoint.Publishing.PublishingPage]::GetPublishingPage($item);

 if($pubPage.VariationPageUrls.Count -eq 0)
 {
     #Page directly created in language sites and not Variated from source
 }
 else #Page Variated
 {
   if($pubPage.Label.IsSource) # then check if the web is Label IsSource
   {
     #this page is variation source
   }
 }
}

Hope this will help, happy learning.