Skip to content

Instantly share code, notes, and snippets.

View keyan1603's full-sized avatar

Karthikeyan Manickavasagam keyan1603

View GitHub Profile
@keyan1603
keyan1603 / UpdateWorkflow.ps1
Last active September 20, 2023 18:06
Sitecore SPE Script to update workflow states under specific node
Write-Host "Starting work in the context of the 'master' database, under /sitecore/content/website1/Data item."
Set-Location -Path "master:/sitecore/content/website1/Data"
# Set up variables
$workflowState1 = "{xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" #ID of the workflow states.
$workflowState2 = "{yyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy}"
$workflowState3 = "{zzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz}"
function Update-Workflows {
@keyan1603
keyan1603 / Sitecore.Reflection.Spefix.config
Last active September 20, 2023 18:05
Fix Sitecore SPE Receive-File modal in 10.x after patching Sitecore critical vulnerabilities
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:security="http://www.sitecore.net/xmlconfig/security/" xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore role:require="ContentManagement or Standalone">
<reflection>
<allowedMethods>
<descriptor type="Spe.Client.Applications.UploadFile.PowerShellUploadFileForm" methodName="CancelClick" assemblyName="Spe" hint="Cancel"/>
<descriptor type="Spe.Client.Applications.UploadFile.PowerShellUploadFileForm" methodName="OKClick" assemblyName="Spe" hint="Ok"/>
<descriptor type="Spe.Client.Applications.UploadFile.PowerShellUploadFileForm" methodName="StartUploading" assemblyName="Spe" hint="StartUploading"/>
<descriptor type="Spe.Client.Applications.UploadFile.PowerShellUploadFileForm" methodName="EndUploading" assemblyName="Spe" hint="EndUploading"/>
<descriptor type="Spe.Client.Applications.UploadFile.PowerShellUploadFile
@keyan1603
keyan1603 / kubernetesrevert.ps1
Created September 20, 2023 18:07
Revert to Previous release – Disaster recovery in Kubernetes
# Revert to previous deployment
kubectl rollout undo deployments/<deployment name>
#Example: To revert CD deployment to the previous state
kubectl rollout undo deployments/cd
# To get the Revisions which were deployed
kubectl rollout history deployment/<deployment name>
#Example: To get the Revision history of CM
kubectl rollout history deployment/cm
@keyan1603
keyan1603 / kubernetesLoggingExtend.config
Created September 20, 2023 18:09
Extending the default OOTB logging - Windows nodes
{
"LogConfig": {
"sources": [
{
"type": "EventLog",
"startAtOldestRecord": true,
"eventFormatMultiLine": false,
"channels": [
{
"name": "system",
@keyan1603
keyan1603 / kubectlcommandsamples.ps1
Created September 20, 2023 18:12
Some useful Kubectl commands - Quick reference
# Display list of all contexts in the current machine
kubectl config get-contexts
# Display the current-context
kubectl config current-context
# Set the default context to my-cluster-name
kubectl config use-context <my-cluster-name>
# Get all the nodes
@keyan1603
keyan1603 / powershellgist.ps1
Last active May 16, 2024 08:24
Kubernetes - Some useful Powershell commands
# Get into Windows Pod and access Powershell inside the pod
kubectl exec -it <podname> -- powershell
# To view the content inside a file, for example web.config
Get-Content web.config
# Get top 100 lines of the file
Get-Content web.config -First 100
# Get last 100 lines of the file
@keyan1603
keyan1603 / docker-compose-override.yml
Created September 20, 2023 18:14
Adding modules to your Sitecore containers
cm:
image: ${REGISTRY}${COMPOSE_PROJECT_NAME}-xp1-cm:${VERSION:-latest}
build:
context: ./docker/build/cm
args:
BASE_IMAGE: ${SITECORE_DOCKER_REGISTRY}sitecore-xp1-cm:${SITECORE_VERSION}
SPE_IMAGE: ${SITECORE_MODULE_REGISTRY}sitecore-spe-assets:${SPE_VERSION}
SXA_IMAGE: ${SITECORE_MODULE_REGISTRY}sitecore-sxa-xp1-assets:${SXA_VERSION}
TOOLING_IMAGE: ${SITECORE_TOOLS_REGISTRY}sitecore-docker-tools-assets:${TOOLS_VERSION}
BMF_IMAGE: konabos/brightcove-sitecore-media-framework:10.1-1809
@keyan1603
keyan1603 / sitecorehelixpowershellbuild.ps1
Created September 20, 2023 18:16
Build Sitecore solution using powershell
RUN Get-ChildItem .\src\Foundation\ –Recurse –Include *.csproj | ForEach-Object { msbuild $_.FullName /p:Configuration=$env:BUILD_CONFIGURATION /p:DeployOnBuild=True /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:PublishUrl=C:\out\website };
RUN Get-ChildItem .\src\Feature\ –Recurse –Include *.csproj | ForEach-Object { msbuild $_.FullName /p:Configuration=$env:BUILD_CONFIGURATION /p:DeployOnBuild=True /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:PublishUrl=C:\out\website };
RUN Get-ChildItem .\src\Project\ –Recurse –Include *.csproj | ForEach-Object { msbuild $_.FullName /p:Configuration=$env:BUILD_CONFIGURATION /p:DeployOnBuild=True /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:PublishUrl=C:\out\website };
#OR
RUN msbuild .\MySitecore.sln /p:Configuration=$env:BUILD_CONFIGURATION /p:DeployOnBuild=True /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:PublishUrl=C:\out\website
@keyan1603
keyan1603 / FixSitecoreShardDB.sql
Created September 20, 2023 18:17
re-use the Sitecore Shard databases after database restore
# Execute below statement in all the shard DBs
UPDATE [__ShardManagement].[ShardsLocal] SET ServerName ='<new db server name>', DatabaseName = '<restored new shard xDB db name with new prefix>'
# Execute below statement in the ShardMapManager DB against each Shard DB
UPDATE [__ShardManagement].[ShardsGlobal] SET ServerName ='<new db server name>', DatabaseName = '<restored new shard xDB db name with new prefix>' WHERE DatabaseName = '<new shard xDB db1 name with old prefix>'
UPDATE [__ShardManagement].[ShardsGlobal] SET ServerName ='<new db server name>', DatabaseName = '<restored new shard xDB db name with new prefix>' WHERE DatabaseName = '<new shard xDB db2 name with old prefix>'
UPDATE [__ShardManagement].[ShardsGlobal] SET ServerName ='<new db server name>', DatabaseName = '<restored new shard xDB db name with new prefix>' WHERE DatabaseName = '<new shard xDB dbn name with old prefix>'
@keyan1603
keyan1603 / GetSitecoreContext.cs
Last active September 20, 2023 18:22
Get Sitecore Context item for a page during AJAX calls
// Get the current URL from the page where the AJAX call has been made
var url = HttpContext.Current.Request.UrlReferrer; // Note the UrlReferrer
// Get the context
var siteContext = SiteContextFactory.GetSiteContext(url.Host, url.PathAndQuery);
if (siteContext?.StartPath == null)
{
throw new Exception(); // log or handle the exception
}