0

When I go to the content editor I can see that the Home item has 81 versions, but when I'm counting its versions in Sitecore Powershell Extensions I'm getting 79 versions as a result.

What am I doing wrong?

Home Item Versions in content editor

The script that I'm using to count the versions is quite simple and it's returning 79 as a result

$item = Get-Item -Path master:\path-tho-the-item\home -Language * -Version *
Write-Host $item.Versions.Count
1
  • There may be some particular versions are deleted, check if you have all the versions. Jul 18, 2022 at 16:03

2 Answers 2

1

It may happen that some of the versions have been deleted or archived. So the screenshot that you added is showing the latest version number which is 81. But if anyone has removed or archived a version between them then Sitecore doesn't reset the count.

For example, here in this screenshot, I have five versions of an item so it's showing the latest version i.e 5.

enter image description here

But I have deleted versions 2 and 3 and if I open the version panel then it shows only those that exist for this item like in the image.

enter image description here

And when I run the below PowerShell script then it shows the correct version count i.e 3.

enter image description here

I think you need to verify and you will get the context.

Hope this helps.

1
  • That makes total sense. Thank you @Sumit Bhatia! Jul 18, 2022 at 17:32
0

Additionally, You can check all the version details by using the below PowerShell script :

Get-Item -Path master:\...\ClientDetails -Language * -Version *

enter image description here

It will show all the version details and we can check easily if we have deleted some version.

1
  • That's exactly how I am getting the items, but the total amount does not match anyway. Jul 18, 2022 at 22:46

Your Answer

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

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