Skip to content

Instantly share code, notes, and snippets.

View fluxdigital's full-sized avatar

Adam Seabridge fluxdigital

View GitHub Profile
@fluxdigital
fluxdigital / codecoverage-github-actions.yml
Last active March 25, 2024 12:58
Git Hub actions yaml file for Code Cov with Sitecore
- name: Setup VSTest Path
uses: darenm/Setup-VSTest@v1.2
- name: Install Coverlet
run: dotnet tool install --global coverlet.console
shell: cmd
- name: Run Coverlet & Unit Tests for all test projects
run: |
$basePath = "."
@fluxdigital
fluxdigital / Sitecore-DB-Maintenance-Plan-Workflow-RB.ps1
Created January 17, 2024 23:33
Azure Runbook Workflow that finds fragmented database tables and re-indexes them
workflow Sitecore-DB-Maintenance-Plan-Workflow-RB
{
<#
.SYNOPSIS
Azure Runbook Workflow that finds fragmented database tables and re-indexes them
.DESCRIPTION
Finds any tables with a average fragmentation higher than the defined $FragPercentage and then indexes them
.PARAMETER SqlServer
Your SQL Server Name (e.g 'my-sql-server.database.windows.net')
.PARAMETER Database
@fluxdigital
fluxdigital / Enable-Disable-Non-Admin-Users.ps1
Last active November 22, 2023 00:10
Script to disable/enable (lock/unlock) all users, but allow a selection of admin users to exclude - includes safey check for 'sitecore/admin' user
<# *** Script to disable/enable all non admin users. Allows a selection of admin users to exclude - includes safey check for 'sitecore/admin' user *** #>
write-host "Enabling / Disabling users.."
write-host
$options = @{
"Disable"="disable"
"Enable"="enable"
}
@fluxdigital
fluxdigital / IAR-Content-Editor-Warning.ps1
Created November 12, 2023 21:36
Adds IAR Check and message to Content Editor
### Adds IAR Check and message to Content Editor ###
#IARs method for GetItemLocations() are only available in 10.2 an above - so return if Sitecore 9 -> 10.1
$sitecoreversion = [Sitecore.Configuration.About]::Version
if ($sitecoreversion.StartsWith('9') -or $sitecoreversion.StartsWith('10.0') -or $sitecoreversion.StartsWith('10.1'))
{
#Sorry this is only for Sitecore 10.2+ and XMCloud
exit
}
@fluxdigital
fluxdigital / ConvertSitecorePublishFileToCLIJson.ps1
Last active October 29, 2023 19:40
Creates an Sitecore CLI JSON file from an Sitecore Package File
#*** converts an Publish.xml file to the new Sitecore CLI Json format ***
#helper functions
function CheckNamePart($namePart){
$namePart = $namePart.Replace(' ','')
$namePart = $namePart.Replace('{','')
$namePart = $namePart.Replace('}','')
return $namePart
}
@fluxdigital
fluxdigital / Di-ServicesConfigurator.config
Created March 16, 2023 22:34
DI ServicesConfigurator config
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<services>
<configurator type="FluxiDigtal.Foundation.DependencyInjection.ServicesConfigurator, FluxiDigtal.Foundation.DependencyInjection">
</configurator>
</services>
</sitecore>
</configuration>
@fluxdigital
fluxdigital / params-in-dependencyinjection.config
Last active March 16, 2023 23:40
Pass Params in Dependency Injection
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
<sitecore>
<services>
<configurator type="FluxiDigtal.Foundation.DependencyInjection.MvcControllerServicesConfigurator, FluxiDigtal.Foundation.DependencyInjection">
<!--turn on option on CD-->
<param desc="useMyCustomCache" role:require="ContentDelivery">true</param>
</configurator>
</services>
</sitecore>
@fluxdigital
fluxdigital / Unlock-Items-ChatGPT.ps1
Created December 16, 2022 00:21
Unlock Items for User - ChatGPT
# Set the username of the user whose locked items you want to unlock
$username = "admin"
# Get a list of all items locked by the specified user
$lockedItems = Get-ChildItem -Path "master:\" -Recurse | Where-Object {
$_.Locking.IsLocked -and $_.Locking.LockedBy -eq $username
}
# Unlock all items in the list
foreach ($item in $lockedItems) {
@fluxdigital
fluxdigital / Create-Item-ChatGPT.ps1
Created December 16, 2022 00:10
Create Sitecore Item - ChatGPT
# Set the necessary parameters for the new item
$itemName = "My New Item"
$itemTemplate = "{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}" #Sample Item
$parentItemPath = "/sitecore/content/Home"
# Create the new item
$newItem = New-Item -ItemType $itemTemplate -Name $itemName -Path $parentItemPath
# Set the new item's field values
$newItem.Editing.BeginEdit()
<?xml version="1.0" encoding="utf-8" ?>
<configuration
xmlns:patch="http://www.sitecore.net/xmlconfig/"
xmlns:role="http://www.sitecore.net/xmlconfig/role/"
xmlns:search="http://www.sitecore.net/xmlconfig/search/">
<sitecore role:require="Standalone or ContentManagement or ContentDelivery" search:require="solr">
<contentSearch>
<indexConfigurations>
<blogPostSearchIndexConfiguration ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration">
<fieldMap ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration/fieldMap">