Saturday, October 17, 2020

DOS commands tips and tricks

Quick commands 

List the file names and save in text file

dir *.dll /b >files.txt

Friday, October 9, 2020

Sitecore PowerShell Extensions - Read all child items

The following script will read all the child items and display the item names after filtering them based on the template name.



Tuesday, September 29, 2020

Run Windows Apps in Administrator Mode by default

How to run Windows Apps in administrator mode by default?

Step 1
Click on the windows icon and type the app name you want to open in administrator mode by default in my case it was Notepad++ and right-click on the icon to open the file location. 


Step 2
Right-click on Notepad++ and open the properties and click on Advanced and check the Run as administrator. 



Saturday, August 29, 2020

Sitecore Content Security Policy Issue

Sitecore 9+ has added the Content Security Policy custom header in the web.config and this will block any API calls to other domains. 



Open web.config and look for customHeaders

<configuration>

<location path="sitecore">

    <system.webServer>

         <httpProtocol>

                <customHeaders>

                         <httpProtocol>

                                <customHeaders>

                                        <remove name="X-Content-Type-Options"/>

          <remove name="X-XSS-Protection"/>

<remove name="Content-Security-Policy"/>

<add name="X-XSS-Protection" value="1; mode=block"/>

<add name="X-Content-Type-Options" value="nosniff "/>

<add name="Content-Security-Policy" value="default-src 'self' 'unsafe-inline' 'unsafe-eval' https://apps.sitecore.net; img-src 'self' data:; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' 'unsafe-inline' https://fonts.gstatic.com; upgrade-insecure-requests; block-all-mixed-content;"/>

        </customHeaders>

      </httpProtocol>

   </system.webServer>

</location>

</configuration>


Now lets add other domain https://mydomain.com  in CSP.

<configuration>

<location path="sitecore">

    <system.webServer>

         <httpProtocol>

                <customHeaders>

                         <httpProtocol>

                                <customHeaders>

                                        <remove name="X-Content-Type-Options"/>

           <remove name="X-XSS-Protection"/>

<remove name="Content-Security-Policy"/>

<add name="X-XSS-Protection" value="1; mode=block"/>

<add name="X-Content-Type-Options" value="nosniff "/>

<add name="Content-Security-Policy" value="default-src 'self' 'unsafe-inline' 'unsafe-eval' https://apps.sitecore.net https://mydomain.com; img-src 'self' data:; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' 'unsafe-inline' https://fonts.gstatic.com; upgrade-insecure-requests; block-all-mixed-content;"/>

        </customHeaders>

      </httpProtocol>

   </system.webServer>

</location>

</configuration>


Thursday, August 20, 2020

Sitecore Config Patch Files

Here is the collection of Sitecore Patch files I have used.


1. Patch Config to Enable/disable the xDB and the tracker


2. Patch Config to Enable/disable the CDN 

Monday, August 17, 2020

Sitecore PowerShell Extensions - Update Placeholders

The following script reads all child items under the Home node and changes the placeHolder key as per the per defined mapping (old and new) if the rendering type is "JSON rendering"

references:

  1. https://www.kasaku.co.uk/2018/02/28/updating-rendering-placeholders/
  2. https://doc.sitecorepowershell.com/

Sitecore PowerShell - Update Rendering Caching

Following scripts reads all renderings in "/sitecore/layout/Renderings/Project/Feature/Platform" path and updates the caching checkbox Cacheable and VaryByData for all the rendering of "Json Rendering" type.