Sunday, September 27, 2020

#Powershell | #Sitecore | Find a string phrase in the entire content tree.

 $startPath = "master:/sitecore/content/"

Write-Host "Search started $(Get-Date -format 'u')"

 

$list = [System.Collections.ArrayList]@()

$itemsToProcess = Get-ChildItem $startPath -Language * -Recurse

 

 

if($itemsToProcess -ne $null) {

    $itemsToProcess | ForEach-Object { 

        foreach($field in $_.Fields) {

            if($field.Type -eq "Single-Line Text" -or $field.Type -eq "Rich Text" -or $field.Type -eq "General Link") {

                if($field -match '//www.abc.com') {

                    $info = [PSCustomObject]@{

"ID"=$_.ID

    "FieldID"=$field.ID

"FieldName"=$field.Name

"FieldType"=$field.Type

"FieldValue"=$field

}

                    [void]$list.Add($info)

                }

            }

        }

    }

}

Write-Host "Search ended $(Get-Date -format 'u')"

Write-Host "Items found: $($list.Count)"

$list | Format-Table


No comments:

Post a Comment

Please Give Some Comment

Featured post

Sitecore 10 Installation on Docker