2017-11-14 10 views
1

Sitecore 콘텐츠 트리에는 약 3000 개의 기사 목록이 있습니다. 각 기사에는 작성자 필드가 있습니다. 작성자 필드는 유형 드롭 링크입니다. PowerShell 스크립트를 작성하여 각 저자가 작성한 기사를 얻을 수 있도록 노력하고 있습니다.Sitecore Powershell 검색/드롭 다운 필드 별 필터

#This is where all the Authors lives 
cd 'master:/sitecore/content/mysite/Global/Authors Folder' 

#Get all the articles that each author has written 
function ProcessItem($item) 
{ 
$articles = Get-Item master: -Query "/sitecore/content/mySite/Home/Articles/2017//*[@@templatename='Article' and @Author='$item.Id']" 
$articles.Count 
} 

#Get a list of authors 
$itemsToProcess = Get-ChildItem -Recurse . | Where-Object { $_.TemplateName -match "Authors" } 
if($itemsToProcess -ne $null) 
{ 
    $itemsToProcess | foreach {ProcessItem($_)} 
} 

작성자 ID로 기사를 가져 오는 호출은 아무것도 반환하지 않는 것으로 보입니다. 따라서 $articles.Count은 항상 0을 반환합니다. @Author.Value='$item.Id'으로 가려고했지만 결과가 아직 없습니다. 아무도 내가 여기서 잘못 할 수있는 것을 볼 수 있습니까?

답변

0

당신은 하나의 속성에 대해 테스트를 제외하고는 다음과 같이 괄호 안에 조건을 포장해야합니다

$articles = Get-Item master: ` 
    -Query "/sitecore/content/mySite/Home/Articles/2017//*[@@templatename='Article' and @Author='$($item.Id)']"