Skip to content

Instantly share code, notes, and snippets.

@fquintanilla
Created August 3, 2018 21:12
Show Gist options
  • Select an option

  • Save fquintanilla/61f30a1156d819577fd41c5d88f74346 to your computer and use it in GitHub Desktop.

Select an option

Save fquintanilla/61f30a1156d819577fd41c5d88f74346 to your computer and use it in GitHub Desktop.
Powershell report
<#
.SYNOPSIS
Lists all bio detail records that do not have a location selected
.NOTES
Francisco Quintanilla
#>
filter Where-NoLocationSelected {
param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
[Sitecore.Data.Items.Item]$item
)
foreach ($field in $item.Fields)
{
if ($field.Name -eq 'Office Phones' -and ($field.Value -eq '<?xml version="1.0" encoding="utf-16"?><fieldgroups />' -or $field.Value -like '*office=""*'))
{
Write-Host $field.Value
# Return custom object so we can include both the item and the field in the report
@{Item = $item; Field = $field}
break
}
}
}
$items = Get-ChildItem -Path "master:/sitecore/content/Shared Data/People/Biographies/" -Recurse | Where-NoLocationSelected
if($items.Count -eq 0) {
Show-Alert "There are no content items without location selected"
} else {
$props = @{
Title = "Missing Location Report"
InfoTitle = "Content items without location selected"
InfoDescription = 'Lists all content items that do not have a location selected.'
PageSize = 25
}
$items |
Show-ListView @props -Property @{Label="Icon"; Expression={$_.Item.__Icon} },
@{Label="Name"; Expression={$_.Item.DisplayName} },
@{Label="Field Name"; Expression={$_.Field.Name} },
@{Label="Path"; Expression={$_.Item.ItemPath} }
}
Close-Window
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment