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)
@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"
@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 / 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
#
# MongoDB (as a windows service)
#
$mongoDbPath = "$env:SystemDrive\MongoDB"
$mongoDbConfigPath = "$mongoDbPath\mongod.cfg"
$url = "https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-3.2.7.zip"
$zipFile = "$mongoDbPath\mongo.zip"
$unzippedFolderContent ="$mongoDbPath\mongodb-win32-x86_64-2008plus-3.2.7"
if ((Test-Path -path $mongoDbPath) -eq $false)
@phaniav
phaniav / ServiceCollectionExtensions.cs
Created June 5, 2018 02:50 — forked from kamsar/ServiceCollectionExtensions.cs
Automatically register controllers with Sitecore 8.2 IoC container
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using System.Web.Mvc;
using Microsoft.Extensions.DependencyInjection;
@phaniav
phaniav / hosts.ps1
Created December 20, 2017 18:46 — forked from markembling/hosts.ps1
Powershell script for adding/removing/viewing entries to the hosts file.
#
# Powershell script for adding/removing/showing entries to the hosts file.
#
# Known limitations:
# - does not handle entries with comments afterwards ("<ip> <host> # comment")
#
$file = "C:\Windows\System32\drivers\etc\hosts"
function add-host([string]$filename, [string]$ip, [string]$hostname) {