Skip to content

Instantly share code, notes, and snippets.

@phaniav
phaniav / Remove-Sitecore9-Instance.ps1
Created September 28, 2018 21:55 — forked from himadric/Remove-Sitecore9-Instance.ps1
A Powershell script for removing Sitecore 9 instance from local machine
############################################################################################
#This script is created to remove Sitecore 9 instance from local machine.
#This will not uninstall Solr but, it will remove Solr collections.
#The script looks at the Prefix parameter and find out all instances and remove them.
#Change the default values before using the script. Or, pass the values as parameters.
#Usage: .\Remove-Sitecore9-Instance.ps1 -Prefix "xp0"
#Declaimer: This is a destructive script, means, it deletes files, databases etc.
#Use it at your own risk.
<%@ Page Language="C#" AutoEventWireup="true" Debug="true" %>
<!DOCTYPE html>
<head>
<title>Sitecore utilities</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
@phaniav
phaniav / publishing Target config snippet.config
Created February 15, 2019 16:21
Adding new publish target in Sitecore v9
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<!-- https://tothecore.sk/2018/05/10/adding-publishing-targets-in-sitecore-9/ -->
<sitecore>
<eventing defaultProvider="sitecore">
<eventQueueProvider defaultEventQueue="core">
<eventQueue name="web_secondary" patch:after="eventQueue[@name='web']" type="Sitecore.Data.Eventing.$(database)EventQueue, Sitecore.Kernel">
<param ref="dataApis/dataApi[@name='$(database)']" param1="$(name)" />
<param hint="" ref="PropertyStoreProvider/store[@name='$(name)']" />
</eventQueue>
@phaniav
phaniav / RequestTimingFilter.cs
Created March 21, 2019 00:18 — forked from amokan/RequestTimingFilter.cs
example of IResultFilter and IActionFilter
using System.Diagnostics;
using System.Web.Mvc;
namespace YourApp.Web.Infrastructure.Filters
{
/// <summary>
/// Filter to display the execution time of both the action and result
/// </summary>
public class RequestTimingFilter : IActionFilter, IResultFilter
{
@phaniav
phaniav / SitecoreWebRequestLogin.ps1
Created March 21, 2019 15:17
PowerShell snippet to login to Sitecore using Invoke-WebRequest
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$url = 'https://sitecore-cm.domain.com/sitecore/login'
$password = 'yourpasseordhere'
$Body = @{
User = 'username'
password = $password
}
$LoginResponse = Invoke-WebRequest -Uri -Method Post -Headers @{"Content-Type" = "application/x-www-form-urlencoded"} `
@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,
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 / 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
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 / 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.*