Skip to content

Instantly share code, notes, and snippets.

View MartinMiles's full-sized avatar

Martin Miles MartinMiles

View GitHub Profile
@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 March 1, 2025 07:53
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"
@MartinMiles
MartinMiles / Disable-TLS_1.3.ps1
Last active December 17, 2021 21:37
On Windows 11, disables TLS 1.3 over TCP, and start Marketing Automation service
Import-Module WebAdministration;
$XConnectSiteName = "xconnect.dev.local"; # or any other IIS website you'd want to process
if($Params.WindowsBuild -ge 22000){
Function ReplaceWebsiteBinding {
Param(
[string] $sitename,
[string] $oldBinding
);
@MartinMiles
MartinMiles / Watch-CreatedFolder.ps1
Created December 5, 2021 23:46
Watches at some folder for a child folder being created, then triggers some action
$global:MonitoredPath = 'c:\inetpub\wwwroot'
$global:ExpectedDirectory = 'xp.xconnect'
$global:KeepGoing = $true
$IncludeSubfolders = $true
$AttributeFilter = [IO.NotifyFilters]::DirectoryName
try
{
$watcher = New-Object -TypeName System.IO.FileSystemWatcher -Property @{
@MartinMiles
MartinMiles / Disable-TLS_1.3.ps1
Last active January 9, 2024 04:57
Disables TLS 1.3 over TCP for the local IIS
New-Item `
'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Server' `
-Force | Out-Null
New-ItemProperty `
-path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Server' `
-name 'Enabled' -value '0' -PropertyType 'DWord' -Force | Out-Null
New-ItemProperty `
-path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Server' `
@MartinMiles
MartinMiles / ThreadPing.ps1
Created November 7, 2021 01:14
A multithreaded network ping written on PwerShell
Param (
[string[]]$Address = $(1..20 | %{"192.168.1.$_"}),
[int]$Threads = 5
)
write-host "Distributing addresses around jobs"
$JobAddresses = @{}
$CurJob = 0
$CurAddress = 0
while ($CurAddress -lt $Address.count)
@MartinMiles
MartinMiles / Update-Compilers.ps1
Created April 20, 2021 22:45
Updates Microsoft.Net.Compilers and Microsoft.CodeDom.Providers.DotNetCompilerPlatform for th latest version across the whole solution within *.csproj and packages.config files
gci -r -include "*.csproj" | foreach-object { $a = $_.fullname; ( Get-Content -Raw $a -Encoding UTF8) | foreach-object { $_ -replace 'Microsoft.CodeDom.Providers.DotNetCompilerPlatform.\d+.\d+.\d+\\build\\net\d{1,3}\\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props','Microsoft.CodeDom.Providers.DotNetCompilerPlatform.3.6.0\build\net472\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.targets' } | set-content -NoNewLine $a -Encoding UTF8}
gci -r -include "*.csproj" | foreach-object { $a = $_.fullname; ( Get-Content -Raw $a -Encoding UTF8) | foreach-object { $_ -replace 'Microsoft.Net.Compilers.\d+.\d+.\d+','Microsoft.Net.Compilers.3.9.0' } | set-content -NoNewLine $a -Encoding UTF8}
gci -r -include "packages.config" | foreach-object { $a = $_.fullname; ( Get-Content -Raw $a -Encoding UTF8) | foreach-object { $_ -replace '<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="\d+.\d+.\d+" targetFramework="net\d{1,3}" ','<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatfo
@MartinMiles
MartinMiles / Update-ReferencesAndRuntime.ps1
Last active February 15, 2021 09:57
Mass reference and dependency updater for Sitecore upgrades. This one updates Sitecore references for the existing solution and runtime from 8.2.3 to 10.0.1
# You may want to clean up \bin and \obj folders
#Get-ChildItem .\ -include bin,obj -Recurse | ForEach-Object ($_) { Remove-Item $_.FullName -Force -Recurse }
gci -r -include "*.csproj" | foreach-object { $a = $_.fullname; ( Get-Content -Raw $a -Encoding UTF8) | foreach-object { $_ -replace '<Project ToolsVersion="12.0"','<Project ToolsVersion="15.0"' } | set-content -NoNewLine $a -Encoding UTF8}
gci -r -include "*.csproj" | foreach-object { $a = $_.fullname; ( Get-Content -Raw $a -Encoding UTF8) | foreach-object { $_ -replace '<TargetFrameworkVersion>v4\.\d\.\d</TargetFrameworkVersion>','<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>' } | set-content -NoNewLine $a -Encoding UTF8}
gci -r -include "web.config" | foreach-object { $a = $_.fullname; ( Get-Content -Raw $a -Encoding UTF8) | foreach-object { $_ -replace '<compilation debug="true" targetFramework="4.6.1"','<compilation debug="true" targetFramework="4.8"' } | set-content -NoNewLine $a -Encoding UTF8}
@MartinMiles
MartinMiles / Publishing.Service-azure.parameters.json
Created January 24, 2021 02:32
This is the required delta to be added to your azure.parameters.json in order to install Publishing Service into PaaS (modify script values!)
"modules": {
"value": {
"items": [
{
"name": "ps",
"templateLink": "https://yourdomain.com/ps-arm/<version>/azuredeploy.json",
"parameters": {
"templateLinkAccessToken": "Optional access token for the template if stored in Azure storage. Otherwise should be empty string.",
"psMsDeployPackageUrl": "<URL of the WDP file Sitecore Publishing Service *-x64.wdp.zip>",
"psModuleMsDeployPackageUrl": "<URL of the WDP file Sitecore Publishing Module *.scwdp.zip>"