Skip to content

Instantly share code, notes, and snippets.

View eat-sleep-code's full-sized avatar

<eat-sleep-code/> eat-sleep-code

View GitHub Profile
@eat-sleep-code
eat-sleep-code / iis-setup-script.ps1
Last active May 5, 2022 02:13
PowerShell IIS Setup Script
# ========================================================================================================
# SEE END OF FILE FOR EXAMPLE USAGE AND COMMAND THAT WILL BE EXECUTED!
# ========================================================================================================
Function Process-Site-Definitions-Url([string]$xmlUrl, [boolean]$overwrite = $false, [boolean]$removeSite = $false)
{
# GETS CONTENTS OF WEB-HOSTED XML FILE, COPIES THEM TO A TEMPORARY FILE, PROCESSES FILE USING Process-Site-Definitions, AND THEN REMOVES THE TEMPORARY FILE
Import-Module WebAdministration;
[DateTime]$date = Get-Date; # GET CURRENT DATE
[string]$xmlPath = "$env:TEMP\site_definitions_" + $date.ToString("yyyyMMdd") + ".xml"; # SET THE PATH FOR THE LOCAL COPY OF THE XML FILE, IN THE USERS "TEMP" FOLDER
@eat-sleep-code
eat-sleep-code / quick-website-deployment.ps1
Last active August 29, 2015 14:24
Quick Website Deployment
Function QuickWebsiteDeployment([string]$SiteName = "Default Website", [string]$SitePath = 'D:\InetSrv\wwwroot', [string]$SiteUrl = 'http://localhost/', [boolean]$suppressRollbackWarning = $false)
{
# Check to see if production folder exists. If it doesn't exist, exit with errors...
$ProductionPathExists = Test-Path $SitePath;
if ($ProductionPathExists -eq $true)
{
# Check to see if '-Offline' folder exists, if it doesn't we will create it for next time by copying the current production folder and ACLs to a new '-Offline' folder.
$OfflinePathExists = Test-Path $SitePath'-Offline';
if ($OfflinePathExists -eq $false)
{
# === BEGIN EXAMPLE USAGE ==============================================================================
# Unblock-Files -path "C:\InetPub\wwwroot"
# === END EXAMPLE USAGE ================================================================================
Function Unblock-Files([string]$path = "C:\")
{
$folders = dir $path -recurse | Where {$_.PSIsContainer};
foreach($folder in $folders)
{
Get-ChildItem $folder.FullName | Unblock-File -Verbose;
@eat-sleep-code
eat-sleep-code / DictionaryFallback.cs
Last active December 22, 2016 18:59
Sitecore.Web.Pipelines.DictionaryFallback
using Sitecore.Data;
using Sitecore.Data.Items;
using Sitecore.Globalization;
using Sitecore.Pipelines.GetTranslation;
using System.Linq;
using System.Text.RegularExpressions;
namespace Sitecore.Web.Pipelines
{
public class DictionaryFallback
@eat-sleep-code
eat-sleep-code / response-code-of-multiple-urls.ps
Last active February 16, 2017 20:49
This script will allow you to automatically check the response status of multiple URLs to see if the URL is still valid.
# The Excel file containing the list of URLs
$inputFile = "C:\Temp\Input.xlsx"
# The Excel file where output should be saved to
$outputFile = "C:\Temp\Output.xlsx"
# If the page contains the following pattern, it will also be considered a 404 error (in addition to pages that actually return a status of 404).
$patternOfFailure = "*Oops! We couldn't find this page.*"
# Name of worksheet
@eat-sleep-code
eat-sleep-code / url-rewrite-force-https.xml
Last active April 25, 2017 16:37
The following URL Rewrite rule will redirect all HTTP requests to HTTPS.
<configuration>
<system.webServer>
<rewrite>
<rules>
<!-- RULE BEGINS HERE -->
<rule name="HTTP to HTTPS Redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
@eat-sleep-code
eat-sleep-code / url-rewrite-redirect-to-another-domain.xml
Last active April 25, 2017 16:36
The following URL Rewrite rule will will redirect one domain to another. It will retain any subdomains, paths, and/or querystring's that were specified in the original domain.
<configuration>
<system.webServer>
<rewrite>
<rules>
<!-- RULE BEGINS HERE -->
<rule name="Old Domain Redirection" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="true">
<add input="{HTTP_HOST}" pattern="(.*)olddomain.com" />
</conditions>
@eat-sleep-code
eat-sleep-code / field-level-data-encryption-implement.sql
Last active April 25, 2017 16:44
Modern versions of Microsoft SQL Server allow developers to encrypt a specific field or fields in a database table. This is a sample of how to implement field-level data encryption on a password field and a password recovery answer field.
USE Sample;
GO
IF NOT EXISTS
(SELECT * FROM sys.symmetric_keys WHERE symmetric_key_id = 101)
CREATE MASTER KEY ENCRYPTION BY
PASSWORD = 'nYRj7R!@@_^w!y}TS!wRu-%BF7`!3`z)mSGF`E+;Ju==rcr;_nvtQaHtS2NqPk'
GO
CREATE CERTIFICATE Field_Level_Data_Encryption_Certificate
@eat-sleep-code
eat-sleep-code / Coveo.SearchProvider.Custom.config
Last active November 9, 2017 22:15
Include linked PDFs in Coveo for Sitecore index
<!-- Under coveo/defaultIndexConfiguration/fieldMap/fieldNames add the following -->
<fieldType fieldName="FileAttachmentContents" includeForFreeTextSearch="true" isDisplayField="true" settingType="Coveo.Framework.Configuration.FieldConfiguration, Coveo.Framework" />
<!-- Under coveo/defaultIndexConfiguration/documentOptions/fields add the following (adjust the namespace accordingly) -->
<field fieldName="FileAttachmentContents">Search.FileAttachmentContents, Search</field>
@eat-sleep-code
eat-sleep-code / list-files-in-directory.ps1
Last active August 15, 2020 04:34
PowerShell script to write out a list of files in a directory
$input = 'C:\input';
$output = 'C:\file-list.txt';
$files = Get-ChildItem $input -Recurse;
foreach ($file in $files){
$fullName = $file.FullName;
$lastWriteTime = $file.LastWriteTime;
Write-Output "$fullName`t$lastWriteTime" | Out-File -FilePath $output -Append
}