With PSObject, you can merge two different object and create a new custom object which can be used for rendering the results. Instead of using multi-dimensional arrays, this can be a better approach.
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
<# | |
.SYNOPSIS | |
Lists all referenced items by lookup items. | |
.NOTES | |
NEHEMIAH JEYAKUMAR | |
#> | |
# | |
# INPUT / CONFIGURATION | |
# | |
$props = @{ | |
Title = "Lists all referenced items By Lookup Items" | |
Description = "Lists all referenced items By Lookup Items" | |
OkButtonName = "Run Report" | |
CancelButtonName = "Cancel" | |
Parameters = @( | |
@{ Name = "lookupRootItem"; Title = "Lookup Item Root Folder"; Editor = "droptree"; Source = "/sitecore/Content/" } | |
@{ Title = "Note"; Value = "Select the root (folder) of the Lookup Items."; Editor = "info" } | |
) | |
} | |
$result = Read-Variable @props | |
if($result -ne "ok") { | |
Close-Window | |
Exit | |
} | |
filter Where-HasGetReferencePages{ | |
param([Parameter(Mandatory=$TRUE,ValueFromPipeline=$TRUE)][Sitecore.Data.Items.Item]$item) | |
$linkDb = [Sitecore.Globals]::LinkDatabase | |
$referredItems = $linkDb.GetReferrers($item) | |
foreach($rItem in $referredItems) { | |
$pageItem = Get-Item -Path "master:" -ID $rItem.SourceItemID | |
New-Object PSObject @{ LookupItemTitle = $item.Name; PageName = $pageItem.Name; PagePath = $pageItem.Paths.FullPath; PageItem = $pageItem } | |
} | |
} | |
#Start Executing the Report | |
$lookupItems = Get-ChildItem -Path master: -ID $lookupRootItem.ID -Recurse | Where-HasGetReferencePages | |
if ($lookupItems.Count -eq 0) | |
{ | |
Show-Alert "Did not find any items with forms"; | |
} | |
else | |
{ | |
# Setup a hashtable to make a more readable script. | |
$props = @{ | |
InfoTitle = "Pages List" | |
InfoDescription = "Lists all pages with item reference" | |
PageSize = 25 | |
} | |
$lookupItems | Show-ListView @props -Property ` | |
@{ Label = "Lookup Item Name"; Expression = { $_.LookupItemTitle } }, | |
@{ Label = "Page Name"; Expression = { $_.PageName } }, | |
@{ Label = "Page Path"; Expression = { $_.PagePath} }, | |
@{ Label = "Template"; Expression = { $_.PageItem.TemplateName} } | |
} | |
Close-Window | |