0

Can anyone explain what's going on here with this Sitecore Power Shell script?

We have 2 websites set up on 1 Sitecore instance, they're as follows:

/sitecore/content/siteA

/sitecore/content/siteB

The below query returns all items under /sitecore/content/siteA/

$contentsToUpdate = Get-Item master: -Query "/sitecore/content/siteA//*" 

The below query returns all items under /sitecore/content/siteB/

$contentsToUpdate = Get-Item master: -Query "/sitecore/content/siteB//*"

The line below seems to return all items under /sitecore/content/siteA/ but nothing from siteB.

$contentsToUpdate = Get-Item master: -Query "/sitecore/content//*"

I was hoping and expecting that the third example would give me pages under both /siteA/ and /siteB/ but it doesn't seem to be doing that despite all 3 of the commands appearing to access sub-directories fine.

Cheers,

Dan

2
  • 1
    How many items are return from first query? and from second? maybe there are more than max configured in Sitecore? ggullentops.blogspot.com/2016/03/… Feb 8 at 12:12
  • 2
    Could you please check Query.MaxItems setting value. you can check it in showconfig.aspx by running sitecoreinstance/sitecore/admin/showconfig.aspx Feb 8 at 12:16

1 Answer 1

2

As seen in some of the comments, the -Query option is influenced by the maximum items setting in Sitecore. With this parameter set for the command you are essentially running a Sitecore Query.

If you are trying to return items from each site you can use a different parameter set which is not bound by the MaxItems setting.

Example: The following walks the tree by looping through the children of each item.

$contentsToUpdate = Get-ChildItem -Path "master:/sitecore/content" -Recurse
1
  • thanks all! Seems to be the MaxItems issue as it's returning 300 which matches the default setting... I'll try with the -Path option and see what gets returned!
    – Daniel
    Feb 8 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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