Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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>
<%@ 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 / 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.
# Add the Sitecore MyGet repository to PowerShell
#Register-PSRepository -Name SitecoreGallery -SourceLocation https://sitecore.myget.org/F/sc-powershell/api/v2
# Install the Sitecore Install Framwork module
#Install-Module SitecoreInstallFramework
# Install the Sitecore Fundamentals module (provides additional functionality for local installations like creating self-signed certificates)
#Install-Module SitecoreFundamentals
# Import the modules into your current PowerShell context (if necessary)
@phaniav
phaniav / Install-Solr.ps1
Created August 29, 2018 13:46 — forked from jermdavis/Install-Solr.ps1
A PowerShell script to help installing Solr as a service - See https://jermdavis.wordpress.com/2017/10/30/low-effort-solr-installs/ for details
Param(
$solrVersion = "6.6.2",
$installFolder = "c:\solr",
$solrPort = "8983",
$solrHost = "solr",
$solrSSL = $true,
$nssmVersion = "2.24",
$JREVersion = "1.8.0_151"
)
# Install Chocolatey if it's not already installed
if (-Not (Get-Command -Name choco -ErrorAction SilentlyContinue)) {
Set-ExecutionPolicy RemoteSigned
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
refreshenv
}
# Core (All Machines)
choco install 7zip.install -y
choco install googlechrome -y
@phaniav
phaniav / CreateAdminLoginUser.sql
Created June 5, 2018 21:01
Script to create a sql admin login user in T-SQL
CREATE LOGIN NewAdminName WITH PASSWORD = 'ABCD'
GO
--Here is how you create a User with db_owner privileges using the Login you just declared:
Use YourDatabase;
GO
IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'NewAdminName')
BEGIN
CREATE USER [NewAdminName] FOR LOGIN [NewAdminName]
EXEC sp_addrolemember N'db_owner', N'NewAdminName'
Download locaton: https://download.microsoft.com/download/B/F/2/BF2EDBB8-004D-47F3-AA2B-FEA897591599/SQLServer2016-SSEI-Expr.exe