View CleanupFields.sql
-- Find field data not associated with an item. | |
SELECT Id FROM SharedFields f | |
WHERE NOT EXISTS (SELECT ID FROM Items i WHERE i.ID = f.ItemId) | |
SELECT Id FROM UnversionedFields f | |
WHERE NOT EXISTS (SELECT ID FROM Items i WHERE i.ID = f.ItemId) | |
SELECT Id FROM VersionedFields f | |
WHERE NOT EXISTS (SELECT ID FROM Items i WHERE i.ID = f.ItemId) |
View ScopeQueryToSearchStringModels.ps1
#$provider = [Sitecore.DependencyInjection.ServiceLocator]::ServiceProvider.GetService([Sitecore.XA.Foundation.Abstractions.Configuration.IConfiguration[Sitecore.XA.Foundation.Search.SearchConfiguration]]).GetConfiguration().QueryMaxItems | |
$query = "+template:{51ed5851-1a61-4dae-b803-6c7fae6b43d8};+sxa:SameFirstTagAsCurrentPage|SxaTags;custom:EventStartDate|[NOW TO *];custom:EventEndDate|[NOW TO *];sort:eventstartdate;sort:isfeatured[desc]" | |
$modelList = [Sitecore.ContentSearch.Utilities.SearchStringModel]::ParseDatasourceString($query) | |
$contextItem = Get-Item -Path "master:" -ID "{31318AEE-310B-4EE4-84DA-4B84471E0FCA}" | |
[Sitecore.DependencyInjection.ServiceLocator]::ServiceProvider.GetService([Sitecore.XA.Foundation.Search.Services.ISearchQueryTokenResolver]).Resolve($modelList, $contextItem) | |
class CustomSearchResultItem : SearchResultItem | |
{ | |
[Sitecore.ContentSearch.IndexField("eventstartdate_tdt")] |
View ReportAndRemoveBustedLanguageFields.ps1
$sql = @" | |
SELECT DISTINCT i.* FROM [dbo].[Items] i | |
INNER JOIN [dbo].[VersionedFields] v | |
ON i.ID = v.ItemId | |
WHERE v.[Language] = '' | |
--SELECT COUNT(*) AS COUNT FROM [VersionedFields] WHERE [Language] = '' | |
--DELETE FROM [VersionedFields] WHERE [Language] = '' | |
"@ |
View CompareTwoIndexes.ps1
# This is a ScopeQuery item found in SXA. You don't have to use this. | |
$scopeItem = Get-Item -Path "master:" -ID "{648F4C3A-C9EA-4FCF-82A3-39ED2AC90A06}" | |
# If not using SXA, you can replace this with the string from the QueryBuilder field type. | |
$scopeQuery = $scopeItem.ScopeQuery | |
$props = @{ | |
Index = "sitecore_sxa_master_index" | |
ScopeQuery = $scopeQuery | |
} | |
$referenceList = Find-Item @props |
View ImportRainbowItemBulk.cs
using System.Collections.Concurrent; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Management.Automation; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using Kamsar.WebConsole; | |
using Rainbow.Model; | |
using Rainbow.Storage.Sc.Deserialization; | |
using Sitecore.Data; |
View CreateRunspaces.ps1
$watch = [System.Diagnostics.Stopwatch]::StartNew() | |
# BLOCK 1: Create and open runspace pool, setup runspaces array with min and max threads | |
$pool = [RunspaceFactory]::CreateRunspacePool(1, [int]$env:NUMBER_OF_PROCESSORS+1) | |
$pool.Open() | |
$runspaces = $results = @() | |
# BLOCK 2: Create reusable scriptblock. This is the workhorse of the runspace. Think of it as a function. | |
$scriptblock = { | |
param ( | |
[string]$Data |
View ExportAccess.ps1
# Use this report to export current access | |
$users = Get-User -Filter * | Where-Object { $_.Roles.Count -gt 0 } | |
$records = [System.Collections.ArrayList]@() | |
foreach($user in $users) { | |
$record = [PSCustomObject]@{ | |
"Username" = $user.Name | |
"Roles" = ($user.Roles | Select-Object -ExpandProperty Name) -join "," | |
} | |
$records.Add($record) > $null |
View DeleteFromPublishingJobQueue.ps1
Import-Function -Name Invoke-SqlCommand | |
$connection = [Sitecore.Configuration.Settings]::GetConnectionString("master") | |
$query = @" | |
DELETE TOP (1000) | |
FROM [dbo].[Publishing_JobQueue] | |
SELECT COUNT(*) QueueCount | |
FROM [dbo].[Publishing_JobQueue] | |
"@ |
NewerOlder