Skip to content

Instantly share code, notes, and snippets.

View MartinMiles's full-sized avatar

Martin Miles MartinMiles

View GitHub Profile
@MartinMiles
MartinMiles / z.ExternalDatabase.config
Created August 7, 2024 17:52
XM Cloud config to plug external database via SQL containers
<?xml version="1.0" encoding="UTF-8"?>
<configuration
xmlns:patch="www.sitecore.net/.../">
<sitecore>
<eventing defaultProvider="sitecore">
<eventQueueProvider>
<eventQueue name="rrh" patch:after="evertQueue[@name='web']" type="Sitecore.Data.Eventing.$(database)EventQueue, Sitecore.Kernel">
<param ref="dataApis/dataApi[@name='$(database)']" param1="$(name)" />
<param ref="PropertyStoreProvider/store[@name='$(name)']" />
</eventQueue>

Kubectl plugin

This plugin adds completion for the Kubernetes cluster manager, as well as some aliases for common kubectl commands.

To use it, add kubectl to the plugins array in your zshrc file:

plugins=(... kubectl)
@MartinMiles
MartinMiles / Download-SitecoreWebFolder.ps1
Created May 10, 2024 22:28
Downloads Sitecore web folder (or subfolder) in a zip archive and then cleans up after itself, leaving no traces of download.
# Define the path to the Sitecore bin directory
$folderName = "App_Config";
$websiteName = "you_site_name"
$binPath = "C:\inetpub\wwwroot\$websiteName\$folderName"
# Define the destination for the temporary zip file
$zipFilePath = "C:\inetpub\wwwroot\$websiteName\temp\$folderName.zip"
# Define exclusions
@MartinMiles
MartinMiles / Install-WindowsTerminal.ps1
Created April 19, 2024 15:29
Install Windows Terminal by PowerShell on Windows Server
# Provide URL to newest version of Windows Terminal Application
$url = 'https://github.com/microsoft/terminal/releases/download/v1.16.10261.0/Microsoft.WindowsTerminal_Win10_1.16.10261.0_8wekyb3d8bbwe.msixbundle'
$split = Split-Path $url -Leaf
# Prerequisites
Start-BitsTransfer -Source 'https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx' `
-Destination $home\Microsoft.VCLibs.x86.14.00.Desktop.appx
Add-AppxPackage $home\Microsoft.VCLibs.x86.14.00.Desktop.appx
# Download
@MartinMiles
MartinMiles / install-latest-docker-without-desktop.ps1
Created April 8, 2024 05:28
Installs latest docker without desktop
#Run as Admin
# https://gist.github.com/jermdavis/6fb0a6e47d6f1342c089af4c04d29c35#file-1_install-docker-ps1
param(
[string]$dockerEnginePath = "C:\",
[string]$dockerInstallPath = "C:\Docker",
[string]$dockerEngineUrl = "https://download.docker.com/win/static/stable/x86_64/docker-24.0.6.zip",
[string]$dockerZip = "docker.zip",
@MartinMiles
MartinMiles / Demo-UploadPicture.ps1
Last active April 20, 2024 17:28
Demo of uploading a media item to XM Cloud using Authoring GraphQL API
# before starting, make sure env variable "Sitecore_GraphQL_ExposePlayground" is set to "true"
$FileToUpload = "C:\Users\Martin\Pictures\man2x.png"
$MediaDestination = "Default Website/new media"
$Hostname = "xmc-perficient-introduction-158.sitecorecloud.io"
# First, obtain TWT using authorized data from user.json
$JWT = .\Request-Token.ps1
# Next, get the upload URL from Authoring GraphQL endpoint
@MartinMiles
MartinMiles / Get-ItemsXmCloud.ps1
Created March 12, 2023 02:58
SPE snipped to return items from MASTER database of my XM Cloud instance
$sql = @"
USE [{0}]
SELECT ID, [Name], [TemplateID], Created from [dbo].[Items]
"@
Import-Function Invoke-SqlCommand
Write-Verbose "Cleaning up the History, EventQueue, and PublishQueue tables in the $($db.Name) database."
$connection = [Sitecore.Configuration.Settings]::GetConnectionString("master")
$builder = New-Object System.Data.SqlClient.SqlConnectionStringBuilder $connection
@MartinMiles
MartinMiles / Convert-UnicornToSCS.ps1
Created February 16, 2023 20:26
Converts Unicorn configurations into Sitecore CLI serialization (to be reworked to cover more configurations, use and an example)
$rootFolder = "C:\Projects\Upgrade\SC\src"
$files = Get-ChildItem -Filter *serialization.config -Path $rootFolder -Recurse
foreach($file in $files)
{
$newSerializationJson = New-Object -TypeName pscustomobject
Write-Host "Convert Started: " + $file.FullName
@MartinMiles
MartinMiles / Evaluate-InstanceAssets.ps1
Last active May 18, 2023 17:24
SPE script used for evaluation of rendering of the solution assets
write-host 'Running script...'
Set-Location master:\content
$pages = get-item 'master:\content\Site or Tenant' | get-childitem -Recurse
$device = Get-LayoutDevice -Default
$Results = @();
foreach($page in $pages){
$renderings = Get-Rendering -Item $page -Device $device -FinalLayout
@MartinMiles
MartinMiles / Allow-RemoteDesktopUserWithoutPassword.ps1
Created January 24, 2022 00:52
Allows policy for users without password to RDP to a given machine
$name = $PSScriptRoot + "\" + $MyInvocation.MyCommand.Name
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$name`"" -Verb RunAs; exit }
$registryPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa"
$Name = "LimitBlankPasswordUse"
$value = "0"