Getting Started Quickly with #Sitecore CDP (Customer Data Platform)

Sitecore CDP formerly Boxever is something you are probably hearing a lot about these days. As a developer you can implement it easily and as a marketer you can take advantage of some of the features as soon as it is implemented. Here are the steps in order I did to get started.

1. Get a sandbox account.

Should be able to get a login for the CDB Sandbox from your Sitecore rep. You can find the sandbox site here. This is a shared sandbox so you will need to be careful not to change anything that someone else has setup. It is ok to look and see what others have setup. That is one advantage of a shared sandbox.

When you first login to your sandbox account you should see a message like this:

2. Get your keys and Create Point of Sale Value.

To get your keys go to the gear icon at the bottom left and select System Settings then API Access.

Copy both keys. Please note in my example I did not use the API Token.

3. Create Point of Sale

Selected System Setting then Point of Sale. Click on the create button and fill out the required fields. In my case since I am using the Lighthouse Demo I called my POS LighthousePOS. Well I can’t remember if I created or it was already out there.

4. Implement code. (SXA Example)

The next step is to implement the script needed to integrate CDP with your site. The script should look like the following. As of this blog the target version should be 1.2 and s.src should be 1.4.8. You will need to add your client key.

// Define the Boxever queue
   var _boxeverq = _boxeverq || [];
   // Define the Boxever settings
   var _boxever_settings = {
       client_key: 'client key goes here', // Replace with your client key
       target: 'https://api.boxever.com/v1.2', // Replace with your API target endpoint specific to your data center region
       cookie_domain: '.lighthouse.localhost', // Replace with the top level cookie domain of the website that is being integrated e.g ".example.com" and not "www.example.com"
       pointOfSale: "LighthousePOS",
       web_flow_target: "https://d35vb5cccm4xzp.cloudfront.net"
};
   // Import the Boxever library asynchronously
   (function() {
        var s = document.createElement('script'); s.type = 'text/javascript'; s.async = true;
        s.src = 'https://d1mj578wat5n4o.cloudfront.net/boxever-1.4.8.min.js';
        var x = document.getElementsByTagName('script')[0]; x.parentNode.insertBefore(s, x);
    })();

I kept this pretty simple and for now created a script and put it under the Base Themes\Main Theme\Scripts folder. I created a script item called cdp-script.

5. Create an Experiment

From the menu expand Experiments and choose Web. Click on the Create Experiment button.

From there you want to click on the add variant button.

After you click on Add Variant there will be a side menu that will appear. Choose My Library Templates.

We will choose a simple popup takeover.

Change anything you want to. In this case I changed the background and font colors. You can also change HTML and script

Once done, make sure you click on the Save button then Close when you see the checkmark.

You will see the new Popup in a list. Click on the Preview button, enter in your site with the CDP script and click the go button. If everything worked correctly you should see the popup.

Once the site opens, in this case my local demo site you will see the popup created.

Another option to try is Experiences the setup is similar to Experiments. You can find on the same menu as Experiments.

This should get you started. I would take a look at what others have done since it is a public sandbox. There are a lot of possibilities with CDP and we are only scratching the surface. For more information on getting started please take a look at this video that was released as I was putting together this blog.

#Sitecore Lucene to SOLR Index Upgrade Tips

Recently I did a Lucene to SOLR upgrade. Even though SOLR has been out a while you may still run into instances that you may need to upgrade. This I hope gives you a small guide on some of the things you need to do other than installing the SOLR server.

1. Turn on switch and rebuild on indexes. You can find more information about that here. Don’t forget to add your custom indexes as well.

2. Convert string to string[]. I ran into an issue where a field was coming back with a null. Looking at the SOLR server and doing a query I found that the following would come back as null.

["27ae232e906349b083d612f2ebb7a173", "3fd1ef6aac954936bb8133d5f60ebfee", "9b8e4140b9fe4ecb99c41e0454b31b2e"]

Looking at it further found that the following code needed to be changed.

From:
  [IndexField("tags")]
  public string Tags { get; set; }
To:
  [IndexField("tags")]
  public string[] Tags { get; set; }

Basically the string needed to be a string array.

3. Make sure you check the class references.

From:
Sitecore.ContentSearch.LuceneProvider.LuceneSearchIndex, Sitecore.ContentSearch.LuceneProvider
To:
Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider

4. Don’t forget to rebuild the indexes and make sure everything you expect is there.

On a side not every time I hear SOLR I think of this movie.

#Sitecore Hackathon 2022 Adventure. #SCHackathon

Six years doing the Sitecore Hackathon and one thing I learned is each year brings a new challenge. First off I had a great team. Our team name was R-Bacon-Sulting. I worked with two co-workers from RBA. One being a front-end developer and the other being Devops. All we needed was a project manager and a business analyst to complete the team. We chose the third category for the hackathon which was to make an enhancement to the MVP site.

As hard as we tried the goal of adding to the MVP site did not work out since we had trouble getting the site up and running and ran out of time. We did have a great idea and hope to one day we can implement it.

The bottom line is we all learned something and as co-workers we got to know each other better. In the end isn’t this what this mainly is about?

So here we go with the summary of what I learned this year (in Ted Lasso speak) because let’s face it there is always room for improvement. That is why I love what I do.

Under pressure is when we learn that we really have what it takes. We may be in unfamiliar territory, but we adapt and get better because of it.
So many things happen when you don’t succeed. Life is full of surprises. We just have to go with the flow and hope for the best as we learn. Even if it is not the fairy tale you want it is the fairy tale that is best for you to grow professionally.
Yeah I love to code, but you know what else I love to do? I love to teach people about coding. What you learn is always crucial to pass it on to others. Glad I got the opportunity to pass on some Sitecore things to the team and I also learned things from them.
Everyone that participated in the Hackathon will remember the good and the bad. You know what though, next year we need to be a goldfish and approach it like it is something new and exciting. Forget about what went wrong, but focus on the task at hand.
Special shout out to all that put on the Sitecore Hackathon every year and our team from RBA.

#Sitecore #Docker Containers Syncing Database Changes the Lazy Way

I have been using Docker/Containers for about six months. I have to tell you I really like using them. A recent project I am helping architect the solution for I decided to have the other developers use them. There were some hiccups along the way getting some developers setup, but so far it has worked out well. I think I convinced them change is good.

Ted Lasso Memes At Your Service!

Anyway one of the things I have learned is how easy it is to deploy things to containers. One of them being databases. Normally you would install Sitecore and serialize items or use Sitecore packages for changes. We are doing that. However we had multiple sites/tenants to create in SXA and wanted to make sure the team was in sync from the start. With the out of the box Sitecore tools for Docker it is easy to do.

If you look into your docker\data\mssql folder (could be a different folder depending how you setup your volume, but in this case I am using the default) you will find the ldf and mdf files for each Sitecore database. Just copy the ones for the database you want to share and put it in a shared folder for other developers. I actually stored them in Teams.

The developer who is installing the database should do a docker-compose down first. Then copy the database files to their local data\mssql folder. Once they are a copied to the other developer’s local data\mssql folder they will need to do a docker-compose up. Now they will have the same database changes as the other developer for their containerized Sitecore instance. BTW inside the mssql image you can view the database files.

So what happened? Was it magic? Well if you think PowerShell is magic then it was. As with custom web changes databases are also deployed into the images using the built in Sitecore tools. So as soon as the files are copied the watcher does its thing.

So one catch with this that I noticed recently. If you clean out your Docker Data\Deploy folders by running something like the clean.ps1 script it clears out the data\mssql folder. Which means the database changes could be lost. I will look for a workaround for this, but one thing that I did was create a clean script that keeps the database folder contents. See below for an example:

# Clean data folders
Get-ChildItem -Path (Join-Path $PSScriptRoot "\docker\data") -Directory | ForEach-Object {
    $dataPath = $_.FullName

    Get-ChildItem -Path $dataPath -Exclude ".gitkeep", "license.xml", "*.ldf", "*.mdf" -Recurse | Remove-Item -Force -Recurse -Verbose
}

# Clean deploy folders
Get-ChildItem -Path (Join-Path $PSScriptRoot "\docker\deploy") -Directory | ForEach-Object {
    $deployPath = $_.FullName

    Get-ChildItem -Path $deployPath -Exclude ".gitkeep", "license.xml", "*.ldf", "*.mdf" -Recurse | Remove-Item -Force -Recurse -Verbose
}

I will update this blog post I am sure as things evolve with Docker/Containers, but I hope for now this will give one way to share database changes. If you have a better way I would love to know.

#Sitecore Milwaukee In Person Meetup Impressions and Pictures

My favorite Sitecore meetup has been the Milwaukee since I attended my first one. After a long time off a new one was going to be put on by Mike Congdon and Joe Ouimlet. It would take place at Milwaukee Tool. I asked them if they needed a presenter and was honored to be picked. They even got me a six pack of Spotted Cow for speaking. It was worth the 2+ hour drive just for that. 🙂 You can find the full video of the meetup here.

The first speaker was Geoff Morgeene from Milwaukee Tool. Geoff shared tricks and gotchas from using the Sitecore Powershell extension. I learned a lot on his presentation and will definitely use his ideas.

Geoff Morgeene presenting.

The second speaker was me, talking about using Content Hub and webmethods.io. You can check out a few videos on YouTube of me presenting this. If you would like me to present at your meetup let me know.

Look at all those awesome tools.
Joe getting things ready.

Looking forward to the next one.

Extending the BizFX Commerce Tools for #Sitecore Commerce for Simpletons

Sitecore commerce has some really great features and hidden gems. Recently I was given an assignment to create some custom forms for the BizFX tools that come with Sitecore commerce. Excited as I was to get started I found there was not too much documentation on this. I had some help thanks to Andrew Sutherlands blog. There were things though that I ran in to that I had to figure out how to get through. So I want to make sure I can help others who may get into the same situation as me and also if I ever need to to extend the tools again I can look back at this blog and it will help me figure some of the things out.

Understanding the Master Form and Children

Basically you have a master view. This is usually a summary of your records. Clicking on that master form will show its children views. The children could be any type of detail block of information. So lets say you have a summary of services as your master. The children view when breaking it down further could be notes and description, service dates, vendor information etc… The code below is an example on how to add children view(s) to a master view. You need to make sure you are on the correct master view.

[PipelineDisplayName(Constants.Blocks.GetServicesItemsBlock)]
    public class GetServicesItemsBlock : GetTableViewBlock
    {
        private readonly IServiceService _servicesService;

        public GetServicesItemsBlock(IServiceService servicesService)
        {
            _servicesService = servicesService;
        }

        public override Task<EntityView> Run(EntityView entityView, CommercePipelineExecutionContext context)
        {
            Condition.Requires(entityView).IsNotNull($"{this.Name}: The argument can not be null");

            var entityViewArgument = context.CommerceContext.GetObjects<EntityViewArgument>().FirstOrDefault();
            if (entityViewArgument == null || string.IsNullOrEmpty(entityViewArgument.EntityId)) return Task.FromResult(entityView);

            if (!EntityViewExtensions.IsOnServicesView(entityViewArgument)) //Make sure you are on the correct master view
            {
                return Task.FromResult(entityView);
            }
            
            var entityId = long.Parse(entityViewArgument.EntityId.Substring(entityViewArgument.EntityId.LastIndexOf('-') + 1));
            var services =  _servicesService.GetServiceById(entityId);

            EntityView subView = new EntityView
            {
                EntityId = entityId.ToString(), Name = Constants.Headers.Items, UiHint = "Table"
            };

            entityView.ChildViews.Add(subView);

            var servicesItemList = services.Result.ServiceItems;
            if (servicesItemList == null) return Task.FromResult(entityView);

            foreach (var subitem in servicesItemList)
            {
                EntityView lineView = new EntityView
                {
                    EntityId = subView.EntityId, ItemId = services.Result.OrderId, Name = Constants.Headers.Items
                };

                lineView.AddServiceItemChildView(subitem);
                subView.ChildViews.Add(lineView);
            }

            return Task.FromResult(entityView);
        }
    }

For the master you will have code like this if you need to change the properties:

//Current entity which is the the master view is passed in to the block.
public override async Task<EntityView> Run(EntityView arg, CommercePipelineExecutionContext context)

var status = entityViewArgument.ViewName.Replace("ServicesList-", string.Empty);
            arg.Properties.Add(new ViewProperty
            {
                Name = "ListName",
                RawValue = status,
                IsReadOnly = true,
                IsHidden = true,
                IsRequired = false
            });
            arg.UiHint = "Table";
Example Summary

To sum it up the master/child view structure is simple. You have your master view, but then you can add children views and those children can have children views.

For the children you want to generate a new view.

It would be done in this order (see code for reference):

  1. Get the master view.
  2. Create a subview (child view).
  3. Create and add children to the subview.
  4. Add subview to the master entity view.
using System.Linq;
using System.Threading.Tasks;
using Sitecore.Commerce.Core;
using Sitecore.Commerce.EntityViews;
using Sitecore.Framework.Conditions;
using Sitecore.Framework.Pipelines;

namespace PSP.Commerce.Plugin.Service.Pipelines.Blocks
{
    ///<summary>
    ///displays the service items view in BizFx/services.
    ///</summary>
    [PipelineDisplayName(Constants.Blocks.GetServicesItemsBlock)]
    public class GetServicesItemsBlock : GetTableViewBlock
    {
        private readonly IServiceService _serviceService;

        public GetServicessItemsBlock(IServiceService serviceService)
        {
            _serviceService = serviceService;
        }

        public override Task<EntityView> Run(EntityView entityView, CommercePipelineExecutionContext context)
        {
            Condition.Requires(entityView).IsNotNull($"{this.Name}: The argument can not be null");

            var entityViewArgument = context.CommerceContext.GetObjects<EntityViewArgument>().FirstOrDefault();
            if (entityViewArgument == null || string.IsNullOrEmpty(entityViewArgument.EntityId)) return Task.FromResult(entityView);

            if (!EntityViewExtensions.IsOnSubcriptionsView(entityViewArgument))
            {
                return Task.FromResult(entityView);
            }
            
            var entityId = long.Parse(entityViewArgument.EntityId.Substring(entityViewArgument.EntityId.LastIndexOf('-') + 1));
            var service=  _serviceService.GetServiceById(entityId);

            EntityView subView = new EntityView
            {
                EntityId = entityId.ToString(), Name = Constants.Headers.Items, UiHint = "Table"
            };

            entityView.ChildViews.Add(subView);

            var serviceItemList = service.Result.ServiceItems;
            if (serviceItemList == null) return Task.FromResult(entityView);

            foreach (var subitem in serviceItemList)
            {
                EntityView lineView = new EntityView
                {
                    EntityId = subView.EntityId, ItemId = service.Result.OrderId, Name = Constants.Headers.Items
                };

                lineView.AddServiceItemChildView(subitem);
                subView.ChildViews.Add(lineView); 
            }

            return Task.FromResult(entityView);
        }
    }
}

Example child item.

There are many field types you can use for views, but two of them that stood out for me was the EntityLink and HTML field types.

Below is an example of an link type. Which we can create to navigate to other types of views. The Id for instance could be used to retrieve records for the child views.

var idViewProperty = new ViewProperty
                {
                    Name = "Id",
                    RawValue = service.Id,
                    IsReadOnly = true,
                    UiType = "EntityLink"
                };
                entityView.Properties.Add(idViewProperty);

Below is an example of using a UitType of Html to create an image column value.

  var imageLinkProperty = new ViewProperty
            {
                Name = "Image",
                RawValue =  "<a><img src="+ serviceItem.ImageUrl +" alt=" + serviceItem.Name + " width=\"50\" height=\"50\"></a>", //MediaManager.GetMediaUrl(serviceItem.ImageUrl),
                IsReadOnly = true,
                UiType = "Html"
            };
            properties.Add(imageLinkProperty);

Last thing I want to mention is action view buttons. You can easily defined them (see below).

            ActionsPolicy actionsPolicy = entityView.GetPolicy<ActionsPolicy>();
            List<EntityActionView> entityActionView = actionsPolicy.Actions;
            EntityActionView skipEntityActionView = new EntityActionView
            {
                Name = context.GetPolicy<KnownServiceCancelPolicy>().CancelService,
                DisplayName = Constants.Actions.CancelService,
                Description = Constants.Actions.CancelService,
                IsEnabled = true,
                RequiresConfirmation = true,
                EntityView = string.Empty,
                Icon = "delete"
            };
            entityActionView.Add(skipEntityActionView);

            List<EntityActionView> actions2 = actionsPolicy.Actions;
            EntityActionView cancelEntityActionView = new EntityActionView
            {
                Name = context.GetPolicy<KnownServiceSkipPolicy>().SkipService,
                DisplayName = Constants.Actions.SkipService,
                Description = Constants.Actions.SkipService,
                IsEnabled = true,
                RequiresConfirmation = true,
                EntityView = string.Empty,
                Icon = "hand_stop2"
            };
            actions2.Add(cancelEntityActionView);

Here are the results you will see in the view.

Hope this helps you if you are finding this blog. If not please contact me. Thanks.

#Sitecore Hackathon 2021 The Good and Some Bad. #SCHackathon

Hard to believe this was my fifth year doing the Sitecore Hackathon. It has become a tradition though and would not want to miss it. This year my teammate was a co-worker and we were team Alpha Centauri. Get it? We both work for Alpha Solutions. Anyway here is how it went.

Keep Things Simple

Learned this many times in the past. So anything that wasn’t out of the box was off the table. Nothing wrong with trying something new, but as a marathoner I have to stick to the important rule of not trying anything you haven’t practiced on race day.

Well I Missed Something

So I should of read this more closely. We were supposed to use Sitecore 10.1, but for some reason I installed Sitecore 10 update 1 beforehand. So guess what? I broke my own rule and just learned something new. It was McAvoy vs Stewart. Love the reskin BTW.

Some Great Topics to Choose from, but We Need a Solid Idea

This year was the fastest year my hackathon team came up with an idea. One of the topics was Best of SXA. Working with SXA everyday we had come up with a much needed change we felt is needed.

Divide and Conquer

As in past hackathons that I have worked with others, it is always good to come up with roles on the team. I would handle the documentation/video and my teammate would handle the coding. And we were off.

The Finale

After lots of time spent coding and documenting we put something together. Hardest thing for me was getting the video right. There is a reason why I am not a YouTube star. So this is what we came up with.

So that is a wrap. See you all next year!

Basic Authentication with #Sitecore 9.3

A few months back I was given a task to put in basic authentication into Sitecore 9.3. It was mainly from preventing anyone to get into staging sites. I came across and older blog that is currently missing. I wanted to give them credit since it was the inspiration for this blog. You can find the original blog post on the web archives here. I have made some of my own updates including Rules Based Configuration.

using System;
using System.Web;
using Sitecore.Diagnostics;
using Sitecore.Pipelines.HttpRequest;
using System.Text;
using System.Net.Http.Headers;
using System.Linq;

namespace Abc.SharedSource.SitecoreProcessors
{
    public class BasicAuthentication : HttpRequestProcessor
    {
        private bool CheckPassword(string username, string password)
        {
            string[] userlist = Sitecore.Configuration.Settings.GetSetting("BasicAuthUsername").Split(',');
            string[] passwords = Sitecore.Configuration.Settings.GetSetting("BasicAuthPassword").Split(',');

            if(userlist.Contains(username) && passwords.Contains(password))
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        private void AuthenticateUser(string credentials)
        {
            try
            {
                var encoding = Encoding.GetEncoding("iso-8859-1");
                credentials = encoding.GetString(Convert.FromBase64String(credentials));

                int separator = credentials.IndexOf(':');
                string name = credentials.Substring(0, separator);
                string password = credentials.Substring(separator + 1);
             
                if (!CheckPassword(name, password))
                {
                    HttpContext.Current.Response.StatusCode = 401;
                }
            }
            catch
            {
                HttpContext.Current.Response.StatusCode = 401;
            }
        }
        //Basic Auth Code End

        public override void Process(HttpRequestArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            if (Sitecore.Context.Item != null || Sitecore.Context.Database == null || args.Url.ItemPath.Length == 0)
                return;

            if (Sitecore.Configuration.Settings.GetSetting("TurnonBasicAuth") != "True" || Sitecore.Configuration.Settings.GetSetting("TurnonBasicAuth") == "") return;
            if (PatternMatch()) return;
            var request = args.HttpContext.Request;

            var authHeader = request.Headers["Authorization"];
            if (authHeader != null)
            {
                var authHeaderVal = AuthenticationHeaderValue.Parse(authHeader);

                // RFC 2617 sec 1.2, "scheme" name is case-insensitive
                if (authHeaderVal.Scheme.Equals("basic",
                        StringComparison.OrdinalIgnoreCase) &&
                    authHeaderVal.Parameter != null)
                {
                    AuthenticateUser(authHeaderVal.Parameter);
                }
            }
            else
            {
                args.HttpContext.Response.StatusCode = 401;
            }

            if (HttpContext.Current.Response.StatusCode == 401)
            {
                string Realm = Sitecore.Context.Site.TargetHostName;//HttpContext.Current.Request.Url.AbsoluteUri;
                args.HttpContext.Response.Clear();
                args.HttpContext.Response.Headers.Add("WWW-Authenticate",
                    string.Format("Basic realm=\"{0}\"", Realm));
                args.HttpContext.Response.Flush();
                args.HttpContext.Response.End();
            }
        }
        bool PatternMatch()
        {         
            string[] mockUrls = Sitecore.Configuration.Settings.GetSetting("ExcludedPaths").Split(',');
            string url = Sitecore.Context.Site.TargetHostName;// HttpContext.Current.Request.Url.AbsoluteUri;
            foreach (var urlval in mockUrls)
            {
                var containsurl = url.Contains(urlval);
                if(containsurl)
                {
                    return true;
                }
            }
            return false;
        }
    }
}

Since this is Sitecore 9.3 the configuration below is using rules based. 🙂 More than likely you would want to require the ContentManagement role, but you can modify the configuration to use any roles and environments. I put the username and settings in the configuration since Sitecore will also have its own and in this case is only for preventing anyone who accidently finds the site from seeing anything.

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:localenv="http://www.sitecore.net/xmlconfig/localenv/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
<sitecore role:require="ContentManagement, Standalone">
    <pipelines localenv:require="DevBuild or LocalDeveloper">
      <httpRequestBegin>
        <processor type="Abc.SharedSource.SitecoreProcessors.BasicAuthentication, BrookfieldResidential.Extensions"
						   patch:before="processor[@type='Sitecore.Pipelines.HttpRequest.UserResolver, Sitecore.Kernel']"/>
      </httpRequestBegin>
    </pipelines>
    <settings localenv:require="DevBuild or LocalDeveloper">
      <setting name="TurnonBasicAuth" value="True"></setting>
      <setting name="ExcludedPaths" value="media,layouts,speak,/sitecore,/sitecore/admin,brpsc.dev.local/about" />
      <setting name="BasicAuthUsername" value="UserTest1,TestUser2,TesUser3" />
      <setting name="BasicAuthPassword" value="testpass1,testpass2,testpass3" />
    </settings>
  </sitecore>
</configuration>

You should then get the default login screen that looks like this:

#Sitecore Virtual Symposium Kickoff and My Plans #SitecoreSYM @AlphaSolutionUS

2020 sure has had its changes and challenges. Right now Chicago should be alive with Sitecore fans enjoying the best pizza in the world, but that is not possible this year. I am excited nonetheless to enjoy they symposium in the Chicago suburbs and can’t wait for the next few days.

My goal for this year is to concentrate on content marketing and learn as much as I can about the Sitecore Content Hub. That is something I have been excited to learn more about and can’t wait to dive in.

Things kicked off tonight with Happy Hour. I will let the pictures speak, but there was drink making, a chef and magic. Most of all enthusiasm.

Happy Hour
Making Drinks
Some great appetizers.
Magic!
Da Bears! Okay they were not part of the kickoff, but they are playing tonight.

Disabling Identity Server in #Sitecore Installation with #PowerShell

Recently I was given the task to disable the identity login for a dev server. It can be done easily by renaming Sitecore.Owin.Authentication.Disabler.config.example and Sitecore.Owin.Authentication.IdentityServer.Disabler.config.example in the [sitefolder]\App_Config\Include\Examples\ folder. We needed an automated way though. Using the PowerShell script below did the trick.

#SitePhysicalRoot and Prefix are optional. If this script is inserted into a PowerShell install script that has these variables already. In my case XP0-SingleDeveloper.ps1.
#$SitePhysicalRoot = "F:\Sites"
#$Prefix = "testsite123"

$filepath = $SitePhysicalRoot + '\' + $Prefix +'.sc\App_Config\Include\Examples\'
$filelist = @()
$fn1 = 'Sitecore.Owin.Authentication.Disabler.config.example'
$fn2 = 'Sitecore.Owin.Authentication.IdentityServer.Disabler.config.example'
$path1 = $filepath + $fn1
$path2 = $filepath + $fn2
$filelist = @($path1,$path2)

 foreach ($file in $filelist) {
    If (Test-Path $file){
        $rn = $file.replace(".example","")
        Rename-Item -Path $file -NewName $rn
        Write-Output $file was renamed to $rn
    } else {
    "{0} does not exist or already renamed" -f $file
    }
}