Skip to content

Instantly share code, notes, and snippets.

$item = Get-Item master:/content/home
$newTemplate = [Sitecore.Configuration.Factory]::GetDatabase("master").Templates["Sample/Sample Item"];
$item.ChangeTemplate($newTemplate)
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:env="http://www.sitecore.net/xmlconfig/env/">
<!--
Author: https://twitter.com/epetrashen
Details: https://sitecorepc.wordpress.com/2020/08/12/supercharge-your-local-sitecore-instance-with-these-tips/
-->
<sitecore env:require="Local">
<hooks>
<hook type="Sitecore.Diagnostics.HealthMonitorHook, Sitecore.Kernel">
<patch:delete />
</hook>
@phaniav
phaniav / Create Anti-Package.ps1
Created April 5, 2020 23:00 — forked from michaellwest/Create Anti-Package.ps1
Generates an anti-package from the selected package. Requires SPE 3.1.
$response = Show-ModalDialog -HandleParameters @{
"h"="Create an Anti-Package";
"t" = "Select a package that needs an anti-package";
"ic"="People/16x16/box.png";
"ok"="Pick";
"ask"="";
"path"= "packPath:$SitecorePackageFolder";
"mask"="*.zip";
} -Control "Installer.Browse"
select princ.name
, princ.type_desc
, perm.permission_name
, perm.state_desc
, perm.class_desc
, object_name(perm.major_id)
from sys.database_principals princ
left join
sys.database_permissions perm
on perm.grantee_principal_id = princ.principal_id
@phaniav
phaniav / GetTableSizes.sql
Created March 12, 2020 20:22
Get the sizes of all tables in SQL Server database
SELECT
t.NAME AS TableName,
s.Name AS SchemaName,
p.rows,
SUM(a.total_pages) * 8 AS TotalSpaceKB,
CAST(ROUND(((SUM(a.total_pages) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS TotalSpaceMB,
SUM(a.used_pages) * 8 AS UsedSpaceKB,
CAST(ROUND(((SUM(a.used_pages) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS UsedSpaceMB,
(SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB,
CAST(ROUND(((SUM(a.total_pages) - SUM(a.used_pages)) * 8) / 1024.00, 2) AS NUMERIC(36, 2)) AS UnusedSpaceMB
@phaniav
phaniav / Call-SitecoreItemsView
Created August 23, 2019 16:30
Gist to create view in Sitecore database for querying sitecore items by path
--Returns all descendants of the /sitecore/template item
SELECT *
FROM ItemsPath
WHERE ItemPath LIKE '/sitecore/templates%'
--Returns all rows in the WorkflowHistory table for all
--descendants of the news item (/sitecore/content/Home/News)
SELECT WorkflowHistory.*
param(
[Parameter(Mandatory=$true)]
[string]$ResourceGroupName,
[Parameter(Mandatory=$true)]
[string]$AppServiceName
)
. "https://gist.githubusercontent.com/phaniav/6ada460d24cafedd4f6803da66e575d7/raw/90b335930a24667ff12ff75241956eecc4358630/Get-KuduUtility.ps1"
$folderKey = -join ((97..122) | Get-Random -Count 10 | ForEach-Object {[char]$_})
@phaniav
phaniav / PublishManager.asmx
Last active August 8, 2019 14:31
WebService file to deploy and publish Sitecore items during release process. should be deleted at the end of release. - https://jeffdarchuk.com/2019/03/12/remotely-triggering-sitecore-operations-in-azure/
using System.Collections.Generic;
using System.Linq;
using System.Web.Services;
using Sitecore.Jobs;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class PublishManager : System.Web.Services.WebService
function Get-AzureRmWebAppPublishingCredentials($resourceGroupName, $webAppName, $slotName = $null){
if ([string]::IsNullOrWhiteSpace($slotName) -or $slotName.ToLower() -eq "production"){
$resourceType = "Microsoft.Web/sites/config"
$resourceName = "$webAppName/publishingcredentials"
}
else{
$resourceType = "Microsoft.Web/sites/slots/config"
$resourceName = "$webAppName/$slotName/publishingcredentials"
}
$publishingCredentials = Invoke-AzureRmResourceAction -ResourceGroupName $resourceGroupName -ResourceType $resourceType -ResourceName $resourceName -Action list -ApiVersion 2015-08-01 -Force
@phaniav
phaniav / transform-azure-sitecore-config.ps1
Created August 7, 2019 21:11
Perform Transform on Azure WebApp XML file - Sitecore
param(
[string]$KuduPath,
[string[]]$XDTs,
[string]$TenantId,
[string]$SubscriptionId,
[string]$ResourceGroupName,
[string]$WebAppServiceName,
[string]$SlotName = "",
[string]$ServicePrincipalID,
[string]$ServicePrincipalKey,