Skip to content

Instantly share code, notes, and snippets.

@fearthecowboy
fearthecowboy / TestThis.cs
Created October 21, 2014 15:52
Modifying the validation set for a compile-time powershell parameter
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Management.Automation;
using System.Reflection;
using System.Threading;
namespace parametertest
{
@AdamNaj
AdamNaj / 00_Get-ItemsChangedInLast7Days.ps1
Last active February 24, 2016 16:24
SUGCON Presentation
$days = 7;
Get-ChildItem master:\content\home -Recurse |
? { $_."__updated" -gt (Get-Date).AddDays(-$days) } |
Format-Table -Property ID, Name, "__updated", "__updated by"
@AdamNaj
AdamNaj / Get-SitecoreLogTail.ps1
Created September 4, 2015 18:55
Get last 10 lines of the latest sitecore blog.
Get-ChildItem "$($SitecoreLogFolder)\log*.*" | Sort-Object -Descending LastWriteTime | Select-Object -First 1 | Get-Content -Tail 10
@poojarsn
poojarsn / Code-Snippet-1
Last active July 7, 2016 02:12
Sitecore Powershell Extension: Create User defined Template Item
##--INPUT --##
$customTemplateName = "test6";
$baseTemplate="{1930BBEB-7805-47158AC7CF696}|{B7B41C45-2A6-E377DE778095}|{96224572-74-AE7E-DE43F0F6BFD9}";
$layoutRenderings=
'<r xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<d id="{FE5D7FDF-89C0-4D99-9AA3-B5FBD009C9F3}" l="{19432667-2790-44EC-9673-ACAE93AE0519}">
<r id="{7915EF7B--7B0D39137443}" ph="metaheader" uid="{D36E7AFC-08B5-433C13-554B20BE9569}" />
<r id="{016A19CB837-E81F2B510E72}" ph="breadcrumb" uid="{2ABC1220-6C40-426-B0A2-F594EEC98D7E}" />
<r id="{C5CF5F45-F21BAE6-52DBC568E33A}" ph="navheader" uid="{DA646F0700E-B09A26C8}" />
<r id="{93FA9D3A-590A-467C-872F-830C1D17E147}" ph="banner" uid="{8B8E75580AF0C-32620B307B5C}" />
@peplau
peplau / SitecoreRoleConfigurator - Diffs.ps1
Last active September 23, 2016 21:57
Powershell: SitecoreRoleConfigurator - Diffs.ps1
<#
.SYNOPSIS
The following script prompts the user for a Sitecore server role, then shows the files that are not matching the spreadsheet.
Based on Michael West's "SitecoreRoleConfigurator.ps1" - https://gist.github.com/michaellwest/d1124a459cb1fb47486f87d488ecfab8
Important: you will need the CSV file provided by Michael at https://gist.github.com/michaellwest/d1124a459cb1fb47486f87d488ecfab8#file-config_enable-disable_sitecore_8-1_upd3-csv
Now it supports multiple Env Roles separated by comma thanks to @mhwelander feedback
.NOTES
Rodrigo Peplau
2016-09-23
@AdamNaj
AdamNaj / Read-Variable Field Validation.png
Last active October 22, 2016 03:24
Read-Variable field validation
Read-Variable Field Validation.png
#This script will create sitecore items based on given count and template
$InputCount=10
$InputTemplate = Get-Item "master:\templates\Sample\Sample Item"
$result = Read-Variable `
-Parameters @{Name="InputCount"; Title="How many items do you want to create?"},
@{Name="InputTemplate"; Title="Using which template you want to create item?"; root="/sitecore/templates/"} `
-Title "Bulk item create tool" `
-Description "Please provide the number of items and the template that you want to be used"
if($result -eq "ok"){
@RobsonAutomator
RobsonAutomator / dictionary-toolbox-export
Created April 12, 2017 15:25
Simple script to export dictionary domain items
$dialog = Read-Variable -Parameters `
@{ Name = "dictionaryDomain"; Title = "dictionary"; Source="DataSource=/sitecore/content&DatabaseName=master&IncludeTemplatesForDisplay=Dictionary domain" ; Editor="treelist"}, `
@{ Name = "language"; Title = "Language"; Source="DataSource=/sitecore/system/languages" ; Editor="droplist"}, `
@{ Name = "emptyOption"; Value=$true; Title = "Export empty items" ; Editor="bool"} `
-Description "This script will export Dictionary data into file." `
-Width 400 -Height 200 `
-Title "Dictionary Toolbox" `
-OkButtonName "Export" `
-CancelButtonName "Cancel"
@technomaz
technomaz / Restore-Sitecore-items.ps1
Last active August 2, 2018 01:42
Sitecore Powershell script to restore items from recycle bin archived after a certain date (e.g. recently deleted)
[datetime]$archivedDate = [datetime]::Today.AddDays(-1)
Write-Host "Restoring items recycled after $($archivedDate.ToShortDateString())"
foreach($archive in Get-Archive -Name "recyclebin") {
Write-Host " - Found $($archive.GetEntryCount()) entries"
$entries = $archive.GetEntries(0, $archive.GetEntryCount())
foreach($entry in $entries) {
if($entry.ArchiveLocalDate -ge $archivedDate) {
Write-Host "Restoring item: $($entry.OriginalLocation) {$($entry.ArchivalId)}on date $($entry.ArchiveLocalDate)"
$archive.RestoreItem($entry.ArchivalId)