Home Gitesh Portfolio Blog About Me Gallery Contact

Sitecore: Generate Sitemap and export to excel

With this powershell command you will be to generate a sitemap for your sitecore content tree.




Import-Function -Name ConvertTo-Xlsx

$startPath = "master:/sitecore/content"

$list = @()
$itemsToProcess = Get-ChildItem $startPath -Language * -Recurse


if($itemsToProcess -ne $null) {
    $itemsToProcess | ForEach-Object { 
       
         $url = $_.Paths.FullPath -replace "/sitecore/content/", "/"
        $info = [PSCustomObject]@{
                        ItemID=$_.ID
                        ItemName=$_.Name
                        ItemPath=$_.Paths.FullPath
                        ItemUrl = $url
                        ItemTemplate=$_.TemplateName
                        ExistinCM="yes"
                        ExistinCD=""
                    }
        $webPath =  "web:"+$_.Paths.FullPath
        $isItemExistinWeb = Test-Path -Path $webPath
        $isItemExistinWeb
        if($isItemExistinWeb){
            $info.ExistinCD = "yes"
        }
        else{
            $info.ExistinCD = "no"
        }
        
        $list +=$info
      
    }
}

[byte[]]$outobject =  $list | ConvertTo-Xlsx 
Out-Download -Name "itemComparewithCMCD.xlsx" -InputObject $outobject

Posted: 18/05/2022 5:32:29 p.m. by Gitesh Shah | with 0 comments