Skip to content

Instantly share code, notes, and snippets.

@AlexKasaku
Last active August 29, 2015 14:24
Show Gist options
  • Save AlexKasaku/76d9d69e0d919eae2c54 to your computer and use it in GitHub Desktop.
Save AlexKasaku/76d9d69e0d919eae2c54 to your computer and use it in GitHub Desktop.
[Sitecore] Find items of a type, read a multilist field from there, get those items and summarise the relationship.
$courses = gci -r | where-object { $_.TemplateName -ne $null -and $_.TemplateName -eq 'CoursePage' }
ForEach ($course in $courses) {
$subjectAreaField = $course.SubjectArea
if ($subjectAreaField)
{
$subjectAreaIDs = $subjectAreaField -split '\|'
$subjectArray = @()
foreach ($areaID in $subjectAreaIDs)
{
$subjectArea = get-item master: -ID $areaID
if ($subjectArea) {
$subjectArray += $subjectArea.Name.Trim()
}
}
$result = '"' + $course.Name.Trim() + '","' + ($subjectArray -join ",") + '"'
Write-Host $result
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment