I want to get all the items from both master and web database using Find-Item cmdlet and run in one Powershell script. I'd also rather not use Get-Item cmdlet for performance reasons. Any inputs will be much appreciated. Thank you.

Here's the script that I've tried:

$master = Find-Item -Index sitecore_master_index  @{Filter = "Equals"; Field = "_group"; Value = "{C89D37FF-3919-4D89-9925-948B67BD22D9}"}  

$web = Find-Item -Index sitecore_web_index  @{Filter = "Equals"; Field = "_group"; Value = "{C89D37FF-3919-4D89-9925-948B67BD22D9}"}  

$result = $web | Where {$master.ID -NotContains $_.ID}  
  • 1
    Can you give an example of the script you're trying to run? Also, it would be helpful to mention in your question that you'd rather not use Get-Item due to performance reasons. Commented Mar 28, 2019 at 11:37
  • If you just need to compare which items are missing, you can use Compare-Object. Provide the field name which you want to compare and you'll never need to call Get-Item. Check out the #module-spe channel on Sitecore.chat if you would like to have conversations about the module. Commented Mar 28, 2019 at 12:37
  • @MichaelWest Yes, I would just like to compare which items are missing between my master and web databases. I noticed the Context tab only runs the script in one specific database only. I need my script to run in both databases. I also signed up in the channel, just waiting for approval. Thank you.
    – Reena
    Commented Mar 29, 2019 at 2:12

1 Answer 1


Based on your example, you could do the following to compare the results:

$criteria = @(
    @{Filter = "Equals"; Field = "_template"; Value = "{DAF085E8-602E-43A6-8299-038FF171349F}"}

$masterResults = Find-Item -Index "sitecore_master_index" -Criteria $criteria | Select-Object -Property ItemId,DatabaseName
$webResults = Find-Item -Index "sitecore_web_index" -Criteria $criteria | Select-Object -Property ItemId,DatabaseName

Compare-Object -ReferenceObject $masterResults -DifferenceObject $webResults -Property ItemId


From the screenshot below you can see that the objects in the $webResults variable reflects results from the web database.


From the results above, you want to "get" the items from the database, then you'll want to pass the items through Initialize-Item.

Proof that it's from Web

  • thanks for this Sir, but the script you provided is pulling data from the 'sitecore_master_index' only. No data from the web index has been pulled.
    – Reena
    Commented Mar 29, 2019 at 6:48
  • Assuming you changed the item Id in the script, then webResults is empty because the item does not exist. This is as you would expect, right? Commented Mar 29, 2019 at 12:58
  • No Sir, I'm expecting to get data from both master and web, regardless if I get it from both of the databases or through index. The script above only runs on the context item set in the Context tab of the ISE. I noticed that regardless of what index name (e.g sitecore_master_index) i will use on my script, it will only get data from whatever context item i set, I can't set two context items. If that makes sense.
    – Reena
    Commented Mar 30, 2019 at 3:15
  • Hi Maia, I'm not clear on what else your script is doing for you to get data from the context database. From the example I provided above, it demonstrates that items really do come from the web index and web database. Commented Mar 30, 2019 at 3:46
  • Hello Sir, thank you for the update. So even though in my Context item it is set to master:\content\Home, I still get objects from web index and web database, right? I can explicitly compare objects from both indices regardless of what is set on the Context item?
    – Reena
    Commented Mar 31, 2019 at 4:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.