From what I can tell given the above, you are trying to search the entire tree for instances of Dynamics>CRM
and writing the path to a log, you might see some better times from a fast://
query since it does not care about order given the tree compared to the Get-ChildItem
:
$query = "fast:/sitecore/content//*[@Field1 = 'Dynamics>CRM' or @Field2 = 'Dynamics>CRM']"
Get-Item -Path "master:" -Language * -Query $query | ForEach-Object { $_.Paths.FullPath | Write-Log }
You could also try and leverage your indexes:
$root = (Get-Item "master:/sitecore/content/")
Find-Item -Index sitecore_master_index `
-Criteria @{Filter = "DescendantOf"; Field = $root },
@{Filter = "Contains"; Field = "field1"; Value = "Dynamics>CRM"},
@{Filter = "Contains"; Field = "field2"; Value = "Dynamics>CRM"} |
Initialize-Item | ForEach-Object {$_.Paths.FullPath | Write-Log }
I would say the only real deviation from my above scripts to what you provided is defining fields to search by compared to just searching all things everywhere. That tidbit alone might help you speed things up.