<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sitecore Xperiences &#187; Powershell</title>
	<atom:link href="https://blog.peplau.com.br/category/powershell/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.peplau.com.br</link>
	<description>The things I&#039;ve seen as a Sitecore Professional</description>
	<lastBuildDate>Sun, 09 Mar 2025 21:54:22 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.41</generator>
	<item>
		<title>Error enabling GraphQL IDE with XM Cloud</title>
		<link>https://blog.peplau.com.br/error-enabling-graphql-ide-on-xm-cloud/</link>
		<comments>https://blog.peplau.com.br/error-enabling-graphql-ide-on-xm-cloud/#comments</comments>
		<pubDate>Fri, 29 Dec 2023 17:38:18 +0000</pubDate>
		<dc:creator><![CDATA[Rodrigo Peplau]]></dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[XM Cloud]]></category>

		<guid isPermaLink="false">http://blog.peplau.com.br/?p=1025</guid>
		<description><![CDATA[<div class="lr_horizontal_share" data-share-url="https://blog.peplau.com.br/error-enabling-graphql-ide-on-xm-cloud/"></div>Recently, I was exploring the GraphQL IDE with XM Cloud. It comes disabled by default, and for security reasons, it&#8217;s recommended to keep it disabled in Production environments. Enabling it is fairly straightforward, as can be seen in this walkthrough. Or so I thought! Yet, as I attempted to navigate the steps, I encountered errors that left me [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Recently, I was exploring the GraphQL IDE with XM Cloud. It comes disabled by default, and for security reasons, it&#8217;s recommended to keep it disabled in Production environments.</p>
<p>Enabling it is fairly straightforward, as can be seen <a href="https://doc.sitecore.com/xmc/en/developers/xm-cloud/walkthrough--enabling-and-authorizing-requests-to-the-authoring-and-management-api.html" target="_blank">in this walkthrough</a>. Or so I thought! Yet, as I attempted to navigate the steps, I encountered errors that left me feeling like struggling with supposedly &#8220;easy-open&#8221; packages.</p>
<p><div id="attachment_1026" style="width: 620px" class="wp-caption aligncenter"><img class="wp-image-1026 size-full" src="http://blog.peplau.com.br/wp-content/uploads/Packaged-food-new-easy-opening-options1.jpg" alt="Packaged-food-new-easy-opening-options[1]" width="610" height="343" /><p class="wp-caption-text">It always makes me feel stupid when I struggle with &#8220;easy-open&#8221; packages!</p></div>Reaching the section &#8220;<a href="https://doc.sitecore.com/xmc/en/developers/xm-cloud/walkthrough--enabling-and-authorizing-requests-to-the-authoring-and-management-api.html#obtain-an-access-token" target="_blank">Obtain an access token</a>&#8220;, more specifically on step 3 when the &#8220;curl&#8221; command is run, you might see one of the following errors.</p>
<p>With Windows Command Prompt:</p>
<blockquote><p>curl: (3) URL rejected: Port number was not a decimal number between 0 and 65535</p></blockquote>
<p>With PowerShell 5.1:</p>
<blockquote><p>Invoke-WebRequest : A positional parameter cannot be found that accepts argument &#8216;&#8211;request&#8217;.<br />
At line:1 char:1<br />
+ curl &#8211;location &#8211;request POST &#8216;https://auth.sitecorecloud.io/oauth/t &#8230;<br />
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
+ CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException<br />
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand</p></blockquote>
<p>&nbsp;</p>
<h2>Are easy-open packages really easy to open?</h2>
<p>My feelings were correct, and the root cause made me feel stupid: The command only worked well when I ran it in PowerShell 7! It&#8217;s not clear if this is a requirement for this walkthrough only. I&#8217;ve contacted Sitecore and asked for clarifications, as soon as I get a response I&#8217;ll update this article.</p>
<p>To make things a little more confusing, <a href="https://doc.sitecore.com/xmc/en/developers/xm-cloud/walkthrough--setting-up-your-full-stack-xm-cloud-local-development-environment.html" target="_blank">a different walkthrough</a> written by my friend and band partner <a href="https://www.linkedin.com/in/sebastian-winter-506962165/" target="_blank">Sebastian Winter</a>, shows that one of the pre-requisites for using the XM Cloud foundation template is PowerShell 5.1, saying that &#8220;PowerShell 7 is not supported at this time&#8221;.</p>
<p>&nbsp;</p>
<h2>Don&#8217;t have PowerShell 7?</h2>
<p>To find out what version of PowerShell you&#8217;re running, simply type <em>$PSVersionTable</em> at the prompt. If you don&#8217;t have PowerShell 7 installed yet, you can follow <a href="https://learn.microsoft.com/en-us/powershell/scripting/whats-new/migrating-from-windows-powershell-51-to-powershell-7?view=powershell-7.4#installing-powershell-7" target="_blank">this article</a> for instructions on how to install it.</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.peplau.com.br/error-enabling-graphql-ide-on-xm-cloud/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Meet the (Brand new) Advanced Powershell Packaging Features</title>
		<link>https://blog.peplau.com.br/meet-the-brand-new-advanced-powershell-packaging-features/</link>
		<comments>https://blog.peplau.com.br/meet-the-brand-new-advanced-powershell-packaging-features/#comments</comments>
		<pubDate>Thu, 06 Jul 2023 17:26:45 +0000</pubDate>
		<dc:creator><![CDATA[Rodrigo Peplau]]></dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[SPE]]></category>

		<guid isPermaLink="false">http://blog.peplau.com.br/?p=963</guid>
		<description><![CDATA[<div class="lr_horizontal_share" data-share-url="https://blog.peplau.com.br/meet-the-brand-new-advanced-powershell-packaging-features/"></div>TL; DR Sitecore Powershell Extensions (SPE) 7.0 introduces advanced packaging features, but you can also enjoy them in past SPE versions by using our package or Gist. You can now selectively include linked items in packages, avoiding the classic all-or-nothing approach. Learn how the features work and how to use them. &#160; Introduction Get ready [&#8230;]]]></description>
				<content:encoded><![CDATA[<h2>TL; DR</h2>
<ul>
<li>Sitecore Powershell Extensions (SPE) 7.0 introduces advanced packaging features, but you can also enjoy them in past SPE versions <a href="#download-package">by using our package or Gist</a>.</li>
<li>You can now selectively include linked items in packages, avoiding the classic all-or-nothing approach.</li>
<li>Learn how the features work and how to use them.</li>
</ul>
<p>&nbsp;</p>
<h2>Introduction</h2>
<p>Get ready for an exciting update, folks! Sitecore PowerShell Extensions (SPE) 7.0 is rolling out by the end of this year with some seriously cool new features in the packaging department. And guess what? I had the privilege of implementing these features, which were received very positively by the SPE team (shoutout to the amazing <a href="https://www.linkedin.com/in/michaellwest/" target="_blank">Michael West</a> for his support!)</p>
<p>&nbsp;</p>
<h2 id="download-package">Also available for older versions of SPE</h2>
<p>But fear not, even if you&#8217;re using a lower version of SPE, you can still reap the benefits by installing the necessary scripts using the following package: <a href="https://gist.github.com/peplau/6fc0f839330e90e65b987d32b26b2ea4#file-advanced-packaging-features-1-0-zip" target="_blank">Advanced-Packaging-Features-1-0-zip</a>. Or manually creating the 5 scripts at their respective paths <a href="https://gist.github.com/peplau/6fc0f839330e90e65b987d32b26b2ea4" target="_blank">according to this Gist</a>.</p>
<p>Let&#8217;s dive into what these advanced packaging features are all about and how to make the most of them!</p>
<p>&nbsp;</p>
<h2>Rebuild your Link Database</h2>
<p>First things first: the new features depend on the Link Database, so you will have to keep it up-to-date. If you are unsure, remember to give your Link Database a good rebuild for the &#8220;master&#8221; database, at least once before utilizing these features.</p>
<p>&nbsp;</p>
<h2>Unlocking Selective Packaging Superpowers</h2>
<p>Currently, the SPE UI allows you to include linked items in your package, but it is an all-or-nothing deal. If you want to include media items linked to your selected item, you had no choice but to include all of them.</p>
<p>This is how the classic interface works, based on checkboxes:</p>
<p><a href="http://blog.peplau.com.br/wp-content/uploads/01-Classic-Window.png"><img class="alignnone size-full wp-image-967" src="http://blog.peplau.com.br/wp-content/uploads/01-Classic-Window.png" alt="01 - Classic Window" width="471" height="348" /></a></p>
<p>Well, hold on to your keyboards because the new advanced packaging features now empower you to cherry-pick and selectively include linked items to your package.</p>
<p>The new UI will now show a different set of radio box configurations:</p>
<p><a href="http://blog.peplau.com.br/wp-content/uploads/02-New-Window.png"><img class="alignnone size-full wp-image-968" src="http://blog.peplau.com.br/wp-content/uploads/02-New-Window.png" alt="02 - New Window" width="491" height="285" /></a></p>
<ol>
<li><strong>Do not include linked items:</strong> Linked items are not included in the package.</li>
<li><strong>Include parent links only:</strong> Only items linked to the selected item (parent) will be considered for inclusion.</li>
<li><strong>Include all linked items:</strong> All linked items (parent and children) will be considered for inclusion.</li>
</ol>
<p>&nbsp;</p>
<p>If you select either 2 or 3, a new screen will show, allowing you to cherry-pick the linked items you want to include in the package.</p>
<p><a href="http://blog.peplau.com.br/wp-content/uploads/03-New-Select-Linked-Items-window.png"><img class="alignnone size-full wp-image-969" src="http://blog.peplau.com.br/wp-content/uploads/03-New-Select-Linked-Items-window.png" alt="03 - New Select Linked Items window" width="635" height="333" /></a></p>
<p>As you can see, there are tabs for each kind of linked items (Content, Media, Layouts, System, Templates), making the selection process much easier.</p>
<p>&nbsp;</p>
<h2>Using the New Features</h2>
<p>To access these supercharged packaging powers, simply right-click on any item in the Content Editor and navigate to Scripts &gt; Packaging.</p>
<p><a href="http://blog.peplau.com.br/wp-content/uploads/04-Classic-packaging-tools.png"><img class="alignnone size-full wp-image-970" src="http://blog.peplau.com.br/wp-content/uploads/04-Classic-packaging-tools.png" alt="04 - Classic packaging tools" width="617" height="278" /></a></p>
<ul>
<li><strong>Important:</strong> Starting from SPE 7.0 the original features were substituted with the new ones, so you will see the list as above. However, if you’re using the new features in older SPE versions through my package or Gist, then you’ll notice I’ve added the new features to scripts sufixed with “Advanced”, as can be seen below:</li>
</ul>
<p><a href="http://blog.peplau.com.br/wp-content/uploads/05-New-packaging-tools.png"><img class="alignnone size-full wp-image-971" src="http://blog.peplau.com.br/wp-content/uploads/05-New-packaging-tools.png" alt="05 - New packaging tools" width="302" height="276" /></a></p>
<p>Let&#8217;s take a closer look at the options available to fight the packaging confusion crimes, powered by Sitecore PowerShell Extensions:</p>
<p><a href="http://blog.peplau.com.br/wp-content/uploads/06-SPE-Super-hero.jpg"><img class="alignnone size-full wp-image-972" src="http://blog.peplau.com.br/wp-content/uploads/06-SPE-Super-hero.jpg" alt="06 - SPE Super hero" width="270" height="366" /></a></p>
<p>&nbsp;</p>
<h3>Quick Download Tree as a Package (Advanced)</h3>
<p>This option allows you to download as a package the selected item, along with the additional items you choose to include in the package. You can add child items, and selectively pick those linked items that deserve a spot in your package.</p>
<p>&nbsp;</p>
<h3>Start New Package (Advanced)</h3>
<p>Choosing this option initiates the creation of a new package without immediately downloading it. Don&#8217;t worry, though – you&#8217;ll have the option to download it later. Once you&#8217;ve made this selection, a host of further options becomes available:</p>
<ol>
<li><strong>Add Item to Package (Advanced):</strong> This handy feature lets you add the selected item, along with any linked items you desire, to your package.</li>
<li><strong>Add Tree to Package (Advanced):</strong> Selecting this option adds the selected item, all its children, and the linked items you choose to your package.</li>
<li><strong>Preview Package Items (Advanced):</strong> Curious about the contents of your package before sealing the deal? This option lists all the items currently added to your package, allowing you to ensure you&#8217;ve got items you envisioned.</li>
<li><strong>Download Package (Advanced):</strong> Finally, when you&#8217;re ready to unleash your package upon the world, hit &#8220;Download Package&#8221;. Your meticulously crafted package, complete with its formidable lineup of items, will be ready for action!</li>
</ol>
<p>&nbsp;</p>
<h2>Conclusion</h2>
<p>With Sitecore Powershell Extensions 7.0&#8217;s advanced packaging features, you now have the power to curate packages like never before. No more settling for all or nothing – select the linked items that truly matter and assemble the perfect package for your Sitecore adventures. So, go ahead and embrace these newfound packaging superpowers.<br />
Get ready to package up greatness, fellow Sitecore heroes!</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.peplau.com.br/meet-the-brand-new-advanced-powershell-packaging-features/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatic Sitecore NuGet upgrades with Powershell</title>
		<link>https://blog.peplau.com.br/automatic-sitecore-nuget-upgrades-with-powershell/</link>
		<comments>https://blog.peplau.com.br/automatic-sitecore-nuget-upgrades-with-powershell/#comments</comments>
		<pubDate>Tue, 02 Nov 2021 02:05:18 +0000</pubDate>
		<dc:creator><![CDATA[Rodrigo Peplau]]></dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Upgrades]]></category>

		<guid isPermaLink="false">http://blog.peplau.com.br/?p=894</guid>
		<description><![CDATA[<div class="lr_horizontal_share" data-share-url="https://blog.peplau.com.br/automatic-sitecore-nuget-upgrades-with-powershell/"></div>One of the most tedious tasks in any Sitecore upgrade is to update your NuGet references. If your projects have so many NuGet references on packages.config, and in special with Helix solutions, updating everything manually can take you several hours. To the rescue, I&#8217;ve created this Powershell Script, which you can use to save your precious time. What [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>One of the most tedious tasks in any Sitecore upgrade is to update your NuGet references. If your projects have so many NuGet references on <em>packages.config</em>, and in special with Helix solutions, updating everything manually can take you several hours.</p>
<p>To the rescue, I&#8217;ve created this <a href="https://gist.github.com/peplau/450a72767b8a15a61db552560bc8bf9f" target="_blank">Powershell Script</a>, which you can use to save your precious time.</p>
<p>What you need to download:</p>
<ul>
<li>The <a href="https://gist.github.com/peplau/450a72767b8a15a61db552560bc8bf9f" target="_blank">Powershell Script</a> itself</li>
<li>The CSV file with all Sitecore references from <a href="http://www.stockpick.nl/english/sitecore-nuget-dependencies-in-sitecore-101/" target="_blank">this article</a> &#8211; Direct link to the <a href="http://www.stockpick.nl/1/NuGet%20Sitecore.Platform.Assemblies%2010.1.0%20rev.%20005207.csv" target="_blank">CSV file itself is here</a>.<br />
This file is valid for Sitecore 10.1 &#8211; if you need a different version, you will have to prepare and use a different CSV file (Read the article to learn more)</li>
</ul>
<p>Steps to update each project in your solution:</p>
<ul>
<li><strong>Step 1</strong> &#8211; If your upgrade requires, update your Project to the target .NET Framework</li>
<li><strong>Step 2</strong> &#8211; Get the NuGet commands to update your project.</li>
<li><strong>Step 3</strong> &#8211; Run the NuGet commands at the Package Manager Console of Visual Studio</li>
</ul>
<p>It is recommended to update the references gradually, so you can detect and fix any issue as you continue.</p>
<p>In my experience, the following sequence produced good results:</p>
<ol>
<li>If your .NET Framework has changed due to the upgrade, re-install all references not used by Sitecore by running the following command:<br />
<blockquote><p>.\Update-PackagesFile.ps1 -Csv &#8220;C:\temp\NuGet Sitecore.Platform.Assemblies 10.1.0 rev. 005207.csv&#8221; -Packages &#8220;D:\Git\myproject\packages.config&#8221; -ProjectName &#8220;MyProject&#8221; -DumpUnknownReinstall $true</p></blockquote>
</li>
<li>Update the 3rd party references to the target versions, and using this command:<br />
<blockquote><p>.\Update-PackagesFile.ps1 -Csv &#8220;C:\temp\NuGet Sitecore.Platform.Assemblies 10.1.0 rev. 005207.csv&#8221; -Packages &#8220;D:\Git\myproject\packages.config&#8221; -ProjectName &#8220;MyProject&#8221; -DumpKnownReinstall $true</p></blockquote>
</li>
<li>Sometimes 3rd party reference versions didn&#8217;t change, but you still want to force them to reinstall.  If that&#8217;s your case, use the command:<br />
<blockquote><p>.\Update-PackagesFile.ps1 -Csv &#8220;C:\temp\NuGet Sitecore.Platform.Assemblies 10.1.0 rev. 005207.csv&#8221; -Packages &#8220;D:\Git\myproject\packages.config&#8221; -ProjectName &#8220;MyProject&#8221; -DumpKnownReinstall $true</p></blockquote>
</li>
<li>Finally, uninstall and re-install your Sitecore references (useful when migrating from earlier versions into SC10):<br />
<blockquote><p>.\Update-PackagesFile.ps1 -Csv &#8220;C:\temp\NuGet Sitecore.Platform.Assemblies 10.1.0 rev. 005207.csv&#8221; -Packages &#8220;D:\Git\myproject\packages.config&#8221; -ProjectName &#8220;MyProject&#8221; -TargetSitecore &#8220;10.1&#8221; -DumpSitecoreUpdates $true</p></blockquote>
<p>or simply update them with this command:</p>
<blockquote><p>.\Update-PackagesFile.ps1 -Csv &#8220;C:\temp\NuGet Sitecore.Platform.Assemblies 10.1.0 rev. 005207.csv&#8221; -Packages &#8220;D:\Git\myproject\packages.config&#8221; -ProjectName &#8220;MyProject&#8221; -TargetSitecore &#8220;10.1&#8221; -DumpSitecoreUpdates $true -KeepSitecoreLibs $true</p></blockquote>
</li>
</ol>
<p>&nbsp;</p>
<h3>Full description of parameters:</h3>
<ul>
<li><strong>Csv</strong> (mandatory) &#8211; Path to the CSV file</li>
<li><strong>Packages</strong> (mandatory) &#8211; Path to the packages.config file</li>
<li><strong>ProjectName</strong> (mandatory) &#8211; Project Name</li>
<li><strong>TargetSitecore</strong> &#8211; Target Sitecore version</li>
<li><strong>DumpUnknownReinstall</strong> &#8211; If $true =&gt; Will dump the Update-Package with -reinstall commands for libraries not used by Sitecore</li>
<li><strong>DumpKnownUpdates</strong> &#8211; If $true =&gt; Will dump the Update-Package commands for known libraries when versions doesn&#8217;t match</li>
<li><strong>DumpKnownReinstall</strong> &#8211; If $true =&gt; Will dump the Update-Package with -reinstall when versions are the same</li>
<li><strong>DumpSitecoreUpdates</strong> &#8211; If $true =&gt; Will dump the Update-Package for Sitecore.* libraries</li>
<li><strong>KeepSitecoreLibs</strong>
<ul>
<li>If $true  =&gt; then the Sitecore entries will NOT be uninstalled (Update)</li>
<li>If $false =&gt; then the Sitecore entries will be uninstalled and re-installed (useful when migrating from earlier versions into SC10)</li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>https://blog.peplau.com.br/automatic-sitecore-nuget-upgrades-with-powershell/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Index Searching - Find-Item using custom fields with Sitecore Powershell</title>
		<link>https://blog.peplau.com.br/index-searching-find-item-using-custom-fields-with-sitecore-powershell/</link>
		<comments>https://blog.peplau.com.br/index-searching-find-item-using-custom-fields-with-sitecore-powershell/#comments</comments>
		<pubDate>Fri, 05 Jul 2019 17:21:50 +0000</pubDate>
		<dc:creator><![CDATA[Rodrigo Peplau]]></dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[SPE]]></category>

		<guid isPermaLink="false">http://blog.peplau.com.br/?p=768</guid>
		<description><![CDATA[<div class="lr_horizontal_share" data-share-url="https://blog.peplau.com.br/index-searching-find-item-using-custom-fields-with-sitecore-powershell/"></div>UPDATE: Michael West likes this solution and confirmed that it will be part of the next release of SPE (6.0), becoming my first contribution to SPE! Here is the ticket where this implementation is being tracked. If you are a big fan of Sitecore Powershell Extensions like me, you probably know the Find-Item command, which allows searching your search [&#8230;]]]></description>
				<content:encoded><![CDATA[<hr />
<p><em><strong>UPDATE:</strong> <a href="https://github.com/michaellwest" target="_blank">Michael West</a> likes this solution and confirmed that it will be part of the next release of SPE (6.0), becoming my first contribution to SPE! </em><em><a href="https://github.com/SitecorePowerShell/Console/issues/1120" target="_blank">Here is the ticket</a> where this implementation is being tracked.</em></p>
<hr />
<p>If you are a big fan of <a href="https://marketplace.sitecore.net/Modules/Sitecore_PowerShell_console.aspx" target="_blank">Sitecore Powershell Extensions</a> like me, you probably know the <a href="https://doc.sitecorepowershell.com/appendix/indexing/find-item" target="_blank">Find-Item</a> command, which allows searching your search index in Powershell scripts. This command, however, has an important limitation: you cannot use custom fields to filter and sort from the index. Due to this limitation, extended usage of <em>Find-Item</em> with custom code is usually not possible.</p>
<p>Internally <em>Find-Item</em> uses the base class &#8220;<em>Sitecore.ContentSearch.SearchTypes.SearchResultItem</em>&#8220;, which does not include any custom fields. What we usually do with C# is to create a class that inherits from &#8220;<em>SearchResultItem</em>&#8220;, adding our custom fields, such as below:</p>
<pre>public class CustomSearchResultItem : SearchResultItem
{
   [IndexField("_templates")]
   [DataMember]
   public virtual List&lt;ID&gt; TemplateIds { get; set; }
}</pre>
<p>The <em>Find-Item</em> command, however, does not allow using this field. For instance, the following script:</p>
<pre>$props = @{
 Index = "sitecore_master_index"
 Where = "Paths.Contains(@0) And TemplateIds.Contains(@1)"
 WhereValues = [ID]::Parse("{D5B8857B-DE30-4616-84F5-812A7129ACD5}"), [ID]::Parse("{50FFE147-4F48-428B-A417-4D96DD2048FF}")
}
Find-Item @props</pre>
<p>Will give the following error:</p>
<pre>Find-Item : No property or field 'TemplateIds' exists in type 'SearchResultItem'</pre>
<p>Because, yeah&#8230; that property is only defined at our custom class, not at <em>SearchResultItem</em>. To circumvent this limitation I built this special command.</p>
<h2>Find-CustomItem</h2>
<p>This command extends the original <em>Find-Item</em>, allowing you to pass a type that will be used instead of the base <em>SearchResultItem</em> class:</p>
<pre>$props = @{
 Index = "sitecore_master_index"
<strong> Type = [PSWebsite.Foundation.Indexing.SearchTypes.BaseSearchResultItem]</strong>
 Where = "Paths.Contains(@0) And TemplateIds.Contains(@1)"
 WhereValues = [ID]::Parse("{D5B8857B-DE30-4616-84F5-812A7129ACD5}"), [ID]::Parse("{50FFE147-4F48-428B-A417-4D96DD2048FF}")
}
Find-CustomItem @props</pre>
<h2>Create the custom command</h2>
<p>In order to use <em>Find-CustomItem</em> in your project, you should:</p>
<ol>
<li>Add NuGet references to <em>Sitecore.ContextSearch</em> and <em>Sitecore.ContextSearch.Linq</em>;</li>
<li>Add a reference to <em>Cognifide.Powershell.dll</em>;</li>
<li>Create a custom <em>FindItemCommand</em> class extending <em>Cognifide.PowerShell.Commandlets.Data.Search.FindItemCommand</em>;<br />
You can <a href="https://github.com/peplau/PSWebsite/blob/master/src/Foundation/Indexing/code/Powershell/Commandlets/FindItemCommand.cs" target="_blank">download the whole class here</a></li>
<li>Register your new command with an include patch &#8211; make sure the content is according to the following</li>
</ol>
<pre>&lt;?xml version="1.0"?&gt;
&lt;configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"&gt;
   &lt;sitecore&gt;
      &lt;powershell&gt;
         &lt;commandlets&gt;
            &lt;add Name="Find Item" type="PSWebsite.Foundation.Indexing.Powershell.Commandlets.FindItemCommand, PSWebsite.Foundation.Indexing" /&gt;
         &lt;/commandlets&gt;
      &lt;/powershell&gt;
   &lt;/sitecore&gt;
&lt;/configuration&gt;</pre>
<h2>Limitations</h2>
<p>Not all parameters from <em>Find-Item</em> are supported by <em>Find-CustomItem</em>. If you use any of the unsupported parameters along with any custom properties, it will cast the query to the base <em>SearchResultItem</em>, and give the same error as the original <em>Find-Item</em> command.</p>
<p><strong>Supported parameters:</strong></p>
<ul>
<li>Index</li>
<li>Where</li>
<li>WhereValues</li>
<li>OrderBy</li>
<li>First</li>
<li>Last</li>
<li>Skip</li>
</ul>
<p><strong>Unsupported parameters:</strong></p>
<ul>
<li>Criteria</li>
<li>Predicate</li>
<li>ScopeQuery</li>
</ul>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.peplau.com.br/index-searching-find-item-using-custom-fields-with-sitecore-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Powershell script to find TDS files with length error</title>
		<link>https://blog.peplau.com.br/powershell-script-to-find-tds-files-with-length-error/</link>
		<comments>https://blog.peplau.com.br/powershell-script-to-find-tds-files-with-length-error/#comments</comments>
		<pubDate>Mon, 17 Dec 2018 12:49:00 +0000</pubDate>
		<dc:creator><![CDATA[Rodrigo Peplau]]></dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[TDS]]></category>

		<guid isPermaLink="false">http://blog.peplau.com.br/?p=739</guid>
		<description><![CDATA[<div class="lr_horizontal_share" data-share-url="https://blog.peplau.com.br/powershell-script-to-find-tds-files-with-length-error/"></div>A very well described problem with TDS is the File Name length error. This article from Hedgehog brings everything you need to know about the issue itself, and how to work it out. The solution is to use the &#8220;Alias&#8221; TDS feature to cut down the file path length. For instance, if you have an item with a very long [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>A very well described problem with TDS is the File Name length error. <a href="https://www.teamdevelopmentforsitecore.com/Blog/file-length-error-tds" target="_blank">This article</a> from Hedgehog brings everything you need to know about the issue itself, and how to work it out. The solution is to use the &#8220;Alias&#8221; TDS feature to cut down the file path length.</p>
<p>For instance, if you have an item with a very long name such as &#8220;Subpage with Left Rail Without Footer&#8221;, you could choose an Alias as &#8220;sub3&#8243; and save 33 characters. Of course, your original item name is preserved, as this only applies to the file system.</p>
<p>In short:</p>
<ul>
<li>File path should not exceed 260 chars</li>
<li>Folder path should not exceed 248 chars</li>
</ul>
<h2 id="TDSpathlengthissuesolving-Whatcausesandwhattodoabout">What causes and what to do about</h2>
<ol>
<li>You have cloned the repository into a folder with a too large name<br />
<strong>What to do about: </strong></p>
<ol>
<li>Make sure you have something short like:<br />
C:\src\ABC<br />
instead of<br />
C:\Source Control\My Client Name Is Long\My Long Project Name</li>
</ol>
</li>
<li>TDS project name is too wide &#8211; due to the Helix standard TDS projects can have longer names (Eg: <em>MyProject.Foundation.DependencyInjection.Master</em>)<br />
<strong>What to do about:</strong></p>
<ol>
<li>New projects: avoid long names (Eg: DI instead of DependencyInjection)</li>
<li>Existent projects:
<ol>
<li>Use the Powershell script to find long paths and apply Aliases</li>
<li>Be proactive to apply Aliases to TDS long names</li>
</ol>
</li>
</ol>
</li>
<li>The Sitecore Item Path added to TDS (including the item itself) is too long<br />
<strong>What to do about:</strong></p>
<ol>
<li>Use the Powershell script to identify long paths, then apply a TDS Alias to each item that makes it longer</li>
<li>EG: this path<br />
/sitecore/content/mywebsite/This page has a big name/But this page also has a big name/NotToBlame<br />
has 2 problematic items:</p>
<ol>
<li>&#8220;This page has a big name&#8221;</li>
<li>&#8220;But this page also has a big name&#8221;</li>
</ol>
</li>
<li>Those 2 items must be added to TDS and have their &#8220;File System Alias&#8221; setup to something smaller</li>
</ol>
</li>
</ol>
<h2 id="TDSpathlengthissuesolving-Powershellscript">Powershell script</h2>
<p>When a certain environment has this issue, make sure to follow the steps described earlier. However, to execute Step 3 you should first discover what items are problematic.</p>
<p>To quickly obtain such a list, use the following Powershell script:</p>
<blockquote><p># Script Setup<br />
$pathToScan = &#8220;D:\src\ABC&#8221;;<br />
$outputToCsv = $false;<br />
$outputToPrompt = $true;<br />
$maxLength = 225;<br />
#########</p>
<p>cls;</p>
<p>if ($pathToScan.IndexOf(&#8220;\src&#8221;) -eq -1){<br />
$pathToScan = &#8220;$pathToScan\src&#8221;;<br />
}</p>
<p># Get all TDS folders<br />
$tdsFolders = Get-ChildItem -Path $pathToScan -File -Recurse | Where-Object {($_.FullName -like &#8216;*.Master*&#8217;) -or ($_.FullName -like &#8216;*.Core*&#8217;)} | Where-Object {($_.FullName -notlike &#8216;*\bin\*&#8217;)};<br />
#$tdsFolders = Get-ChildItem -Path $pathToScan -Directory -Recurse;</p>
<p># Add properties<br />
foreach ($folder in $tdsFolders){<br />
$folder | Add-Member PathLength $folder.FullName.Length;<br />
}</p>
<p># Sort<br />
$tdsFoldersSorted = $tdsFolders | sort FullName | sort PathLength -Descending;</p>
<p># Get Max Length to filter those that will not match<br />
#$maxLength = Read-Host -Prompt &#8216;Max Length allowed';<br />
$tdsFoldersToShow = $tdsFoldersSorted | Where-Object {$_.PathLength -gt $maxLength};</p>
<p># Output Loop<br />
$fileName = &#8220;$PSScriptRoot\beyond $maxLength.csv&#8221;;<br />
$csvText = &#8220;&#8221;;<br />
if ($outputToCsv){<br />
$csvText = &#8220;$($csvText)Length,FullName`n&#8221;;<br />
#Add-Content -Path $fileName -Value &#8220;Length,FullName&#8221;;<br />
}<br />
if ($outputToPrompt){<br />
Write-Output(&#8220;Length,FullName&#8221;);<br />
}</p>
<p>foreach ($folder in $tdsFoldersToShow){<br />
if ($outputToCsv){<br />
$csvText = &#8220;$($csvText)$($folder.PathLength),$($folder.FullName)`n&#8221;;<br />
#Add-Content -Path $fileName -Value &#8220;$($folder.PathLength),$($folder.FullName)&#8221;;<br />
}<br />
if ($outputToPrompt){<br />
Write-Output(&#8220;$($folder.PathLength),$($folder.FullName)&#8221;);<br />
}<br />
}</p>
<p>if ($outputToCsv){<br />
Add-Content -Path $fileName -Value $csvText;<br />
Write-Output(&#8220;File $fileName saved&#8221;);<br />
}</p></blockquote>
<h3 id="TDSpathlengthissuesolving-Instructions">Instructions</h3>
<ol>
<li>Open the script in Powershell ISE as Administrator</li>
<li>Setup script changing variables at the top:
<ol>
<li><strong>$pathToScan</strong> &#8211; should point to your git folder</li>
<li><strong>$outputToCsv</strong> &#8211; Set as $true if you want the script to create a CSV file with results, $false otherwise</li>
<li><strong>$outputToPrompt</strong> &#8211; Set as $true if you want the script to display results at prompt, $false otherwise</li>
<li><strong>$maxLength</strong> &#8211; Max length tolerated to a TDS item path &#8211; the script will list everything that goes beyond this vale</li>
</ol>
</li>
<li>Run the script</li>
<li>Use the list obtained to apply instructions Aliases, making paths shorter</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>https://blog.peplau.com.br/powershell-script-to-find-tds-files-with-length-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
