Tip for SPE scripts

There was a funny incident that happened with me. I spent a lot of time to understand the script error and changed many things but no luck.

The funniest part was I never touched any part of the script expect the Path of the item in the Query and the script broke with following error:

Get-Item : End of string expected at position 39.
At line:8 char:14
+ ...    $Items = Get-Item -Path master: -Query "/sitecore/content/hbfuller ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-Item], ParseException
    + FullyQualifiedErrorId : Sitecore.Data.Query.ParseException,Microsoft.PowerShell.Commands.GetItemCommand

The only change was I had updated the path in the Query on line number 8. – /sitecore/content/SiteA/Products-and-Technologies/Markets-and-Applications/Transportation/Trailer

The issue was the word “and” was present in the item path, so I had to add “#” in the start and end of the item name containing the word “and” to resolve this issue.

Path: /sitecore/content/SiteA/#Products-and-Technologies#/#Markets-and-Applications#/Transportation/Trailer

Reference link: https://stackoverflow.com/questions/46886106/sitecore-data-query-parseexception-end-of-string-expected-at-position-36

Hope it helps..

Thank you.. Keep Learning.. Keep Sitecoring.. 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s