Skip to content

Instantly share code, notes, and snippets.

@suryagahlot
suryagahlot / Replace field text using Sitecore Powershell.ps1
Created October 26, 2020 11:30
Replace field text using Sitecore Powershell.ps1
$items = Get-ChildItem "master:/sitecore/content/" -Recurse | Where { $_.Fields["Title"].Value -eq "Orthopaedic" }
$index = 0
foreach($item in $items)
{
$index++;
if($index -gt 1){
#break #for testing
$item = Get-Item master:/content/home
$newTemplate = [Sitecore.Configuration.Factory]::GetDatabase("master").Templates["Sample/Sample Item"];
$item.ChangeTemplate($newTemplate)
@suryagahlot
suryagahlot / SPERemoting-SimpleRemoteInstall.ps1
Created September 7, 2019 22:31 — forked from michaellwest/SPERemoting-SimpleRemoteInstall.ps1
Simple example to installing a module package on a remote Sitecore instance. The package already exists on the server.
Import-Module -Name SPE -Force
$packageName = "$($SitecorePackageFolder)\[PACKAGE].zip"
$session = New-ScriptSession -Username "admin" -Password "b" -ConnectionUri "http://remotesitecore"
Test-RemoteConnection -Session $session -Quiet
$jobId = Invoke-RemoteScript -Session $session -ScriptBlock {
[Sitecore.Configuration.Settings+Indexing]::Enabled = $false
Get-SearchIndex | ForEach-Object { Stop-SearchIndex -Name $_.Name }
Import-Package -Path "$($SitecorePackageFolder)\$($using:packageName)" -InstallMode Merge -MergeMode Merge
@suryagahlot
suryagahlot / QueryCleanupQueueCounts.sql
Created September 7, 2019 22:31 — forked from michaellwest/QueryCleanupQueueCounts.sql
Queries the queue tables and counts the number of records using Sitecore PowerShell Extensions.
$sql = @"
USE {0}
SELECT COUNT(*) FROM [SCSitecore_Master].[dbo].[EventQueue]
SELECT COUNT(*) FROM [SCSitecore_Master].[dbo].[PublishQueue]
SELECT COUNT(*) FROM [SCSitecore_Master].[dbo].[History]
"@
Import-Function Invoke-SqlCommand
foreach($db in Get-Database | Where-Object {"filesystem" -notcontains $_ }) {
@suryagahlot
suryagahlot / RemoveEmptyPTags.ps1
Created September 7, 2019 22:11
Remove empty p tags from Richtext fields from all sitecore Items
$items = Get-ChildItem "master:/sitecore/content" -Recurse -Language *
foreach($item in $items){
Write-Host "Item - " $item.Paths.Path
foreach($field in $item.Fields){
if($field.Type -eq "Rich Text"){
$rawValue = $field.Value
@suryagahlot
suryagahlot / OutputMultipleFiles.tt
Created May 1, 2018 13:23 — forked from seankearney/OutputMultipleFiles.tt
This TDS Code Generation template is an example of how you can generate a multiple files that contains a single class in each.
<#@ template language="C#" hostSpecific="true" #>
<#@ import namespace="System" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="HedgehogDevelopment.SitecoreProject.VSIP.CodeGeneration.Models" #>
<#@ parameter name="Model" type="HedgehogDevelopment.SitecoreProject.VSIP.CodeGeneration.Models.SitecoreItem" #>
<#@ parameter name="DefaultNamespace" type="System.String" #>
<#
/************************************************************
@suryagahlot
suryagahlot / frontendDevlopmentBookmarks.md
Created March 10, 2017 19:51 — forked from dypsilon/frontendDevlopmentBookmarks.md
A badass list of frontend development resources I collected over time.