Last active
February 17, 2026 12:50
-
-
Save daivagna/ad11901a8d2d32c7525559bff20aea21 to your computer and use it in GitHub Desktop.
Export to excel of all sitecore items with their renderings and datasource
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Root path | |
| $rootPath = "master:\sitecore\content\<<Tanent name>>\<<site name>>\Home" | |
| # Get ALL items under Home, including children | |
| $items = Get-Item -Path $rootPath | Get-ChildItem -Recurse | |
| echo $items | |
| $exportData = @() | |
| foreach ($item in $items) { | |
| # Collect page fields | |
| $pageFields = @{} | |
| foreach ($field in $item.Fields) { | |
| if ($field.Value) { | |
| $pageFields[$field.Name] = $field.Value | |
| } | |
| } | |
| # Renderings | |
| $renderings = Get-Rendering -Item $item | |
| if ($renderings) { | |
| foreach ($r in $renderings) { | |
| $dsItem = $null | |
| if ($r.Datasource) { | |
| $dsItem = Get-Item -Path ("master:\{0}" -f $r.Datasource) | |
| } | |
| $dsFields = @{} | |
| if ($dsItem) { | |
| foreach ($dsField in $dsItem.Fields) { | |
| if ($dsField.Value) { | |
| $dsFields[$dsField.Name] = $dsField.Value | |
| } | |
| } | |
| } | |
| $exportData += New-Object PSObject -Property @{ | |
| PagePath = $item.Paths.FullPath | |
| PageName = $item.Name | |
| PageTemplate = $item.TemplateName | |
| RenderingID = $r.RenderingItem.ID | |
| RenderingName = $r.RenderingItem.Name | |
| DatasourcePath = if ($dsItem) { $dsItem.Paths.FullPath } else { "" } | |
| DatasourceName = if ($dsItem) { $dsItem.Name } else { "" } | |
| PageFields = ($pageFields.GetEnumerator() | ForEach-Object { "$($_.Key)=$($_.Value)" }) -join "; " | |
| DatasourceFields = ($dsFields.GetEnumerator() | ForEach-Object { "$($_.Key)=$($_.Value)" }) -join "; " | |
| } | |
| } | |
| } | |
| else { | |
| # Include items with no renderings | |
| $exportData += New-Object PSObject -Property @{ | |
| PagePath = $item.Paths.FullPath | |
| PageName = $item.Name | |
| PageTemplate = $item.TemplateName | |
| RenderingID = "" | |
| RenderingName = "" | |
| DatasourcePath = "" | |
| DatasourceName = "" | |
| PageFields = ($pageFields.GetEnumerator() | ForEach-Object { "$($_.Key)=$($_.Value)" }) -join "; " | |
| DatasourceFields = "" | |
| } | |
| } | |
| } | |
| # Export to CSV | |
| $exportData | Export-Csv -Path "C:\daivagna\sitecore-page-export-with-renderings.csv" -NoTypeInformation -Encoding UTF8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment