Last active
August 29, 2015 14:24
-
-
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.
This file contains 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
$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