Skip to content

Instantly share code, notes, and snippets.

@AdamNaj
AdamNaj / Test-Serialization.ps1
Created June 5, 2017 14:38
Unicorn vs Sitecore Serialization compare
$sitecoreSerializationPath = "C:\inetpub\wwwroot\sitecore81\Data\serialization"
$unicornSerializationPath = "C:\Projects\sitecorepowershell\Trunk\Cognifide.PowerShell\serialization"
$serializationIds = gci $sitecoreSerializationPath -filter "*.item" -recurse | Get-Content -first 3 | ? { $_.Startswith("id:") } | % { $_.Substring(5,36).ToLower() }
$unicornIds = gci $unicornSerializationPath -filter "*.yml" -recurse | Get-Content -first 2 | ? { $_.Startswith("ID:") } | % { $_.Substring(5,36) }
"$($serializationIds.Count) items in Sitecore Serialization"
"$($unicornIds.Count) items in Unicorn Serialization"
Write-Host "---- Missing in Unicorn ----"
@AdamNaj
AdamNaj / Screenshot.png
Last active April 10, 2017 11:23
SXA Folder Synchronizer
Screenshot.png
@AdamNaj
AdamNaj / Get-UserRoles.ps1
Last active February 6, 2017 13:53
List Roles for User
function Get-UserRoles{
[CmdletBinding()]
param(
[Parameter(Mandatory=$true, Position=0)]
[string]$Identity
)
$user = Get-User $Identity
return Get-Role -Filter * | Where-Object { $_.IsMember($user,$true,$true) }
}
@AdamNaj
AdamNaj / AuditTemplates.png
Last active February 6, 2017 13:21
Template Usage Audit script
AuditTemplates.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"){
@AdamNaj
AdamNaj / Test-Dialogs.ps1
Last active December 5, 2016 14:28
Dialog Test Script
#Host Color test
$Host.UI.RawUI.BackgroundColor = ($bckgrnd = 'White')
$Host.UI.RawUI.ForegroundColor = 'Black'
$Host.PrivateData.ErrorForegroundColor = 'Red'
$Host.PrivateData.ErrorBackgroundColor = $bckgrnd
$Host.PrivateData.WarningForegroundColor = 'Magenta'
$Host.PrivateData.WarningBackgroundColor = $bckgrnd
$Host.PrivateData.DebugForegroundColor = 'Blue'
$Host.PrivateData.DebugBackgroundColor = $bckgrnd
$Host.PrivateData.VerboseForegroundColor = 'Green'
@AdamNaj
AdamNaj / Read-Variable Field Validation.png
Last active October 22, 2016 03:24
Read-Variable field validation
Read-Variable Field Validation.png
@AdamNaj
AdamNaj / Relink-Test.ps1
Created October 14, 2016 15:21
Working with Links database
@AdamNaj
AdamNaj / Export-ZGShowcase.ps1
Last active August 22, 2016 16:45
ZG Showcase migration
$orderNo=0
$siteDef = gci "master:\content\Showcase Group\Showcase\int\home" -Recurse |
? { $_.Name -ne "Data" -and $_.Parent.Name -ne "Data" -and $_.Parent.Parent.Name -ne "Data" -and $_.Parent.Parent.Parent.Name -ne "Data" -and $_.Parent.Name -ne "Page Data" -and $_.Visualization.Layout -ne $null} |
%{
$orderNo++;
$pageDefinition = [ordered]@{
Name="$($_.Name)";
DisplayName="$($_.DisplayName)";
@AdamNaj
AdamNaj / New-MediaItem.ps1
Last active July 23, 2016 12:43
Create Media item from file on server drive
function New-MediaItem{
[CmdletBinding()]
param(
[Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true)]
[ValidateNotNullOrEmpty()]
[string]$filePath,
[Parameter(Position=1, Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$mediaPath)