I am a sitecore powershellSitecore PowerShell newbie. I
I have to write a sitecore powershellSitecore PowerShell script to ignore certain items from consideration based on their template types. For
For this we can add these items to an array and use -notin-notin
for comparison.
Below is a code sample:
#ignored items list start
$nodeFolderTemplate = Get-Item -Path "/sitecore/templates/System/Node"
$layoutFolderTemplate = Get-Item -Path "/sitecore/templates/System/Layout/Layout Folder"
$rederingFolderTemplate = Get-Item -Path "/sitecore/templates/System/Layout/Renderings/Rendering Folder"
$commonFolderTemplate = Get-Item -Path "/sitecore/templates/Common/Folder"
$placeHolderSettingsFolder = Get-Item -Path "/sitecore/templates/System/Layout/Placeholder Settings Folder"
$branchFolderTemplate = Get-Item -Path "/sitecore/templates/System/Branches/Branch Folder"
$template = Get-Item -Path "/sitecore/templates/System/Templates/Template"
$dictionaryDomain = Get-Item -Path "/sitecore/templates/System/Dictionary/Dictionary Domain"
$dictionaryEntry = Get-Item -Path "/sitecore/templates/System/Dictionary/Dictionary entry"
$ignoredFolders = @( $nodeFolderTemplate.ID, $layoutFolderTemplate.ID, $rederingFolderTemplate.ID, $commonFolderTemplate.ID, $placeHolderSettingsFolder.ID, $branchFolderTemplate.ID )
$ignoredItems = @( $dictionaryDomain.ID, $ignoredFolders.ID, $commonFolderTemplate.ID)
#ignored items list end
$items = Get-ChildItem $selectedValues.SelectedFolderPath -Recurse |
Where-Object { $_.TemplateID -notin $ignoredFolders }
Can anybody please suggest a better way to do it?