Skip to content

Instantly share code, notes, and snippets.

View RobsonAutomator's full-sized avatar

Ro Se RobsonAutomator

View GitHub Profile
@RobsonAutomator
RobsonAutomator / Remove-Items
Last active November 27, 2016 12:41
Remove media items where size is set to 0
cd 'master:/sitecore/media library'
function AddPathMember($item)
{
$path = $item.Paths.Path;
$item | Add-Member -MemberType NoteProperty -Name Path -Value $path;
return $item
}
Get-ChildItem -Recurse . | Where-Object { $_.Size -eq 0 } |
@RobsonAutomator
RobsonAutomator / create-item
Last active January 12, 2017 11:41
Create-Item wrapper for New-Item (New-Item always create new item even item already exist)
function Create-Item
{
<#
.SYNOPSIS
Creates a new item only when an item not exsit.
#>
[cmdletbinding()]
Param(
[Parameter(Mandatory)]
$Path,
@RobsonAutomator
RobsonAutomator / new-handler.ps1
Last active December 14, 2016 13:26
Add handlers to web.config
$webpath = 'E:\www\Sitecore8\Website\Web.config'
#var addElement = handlersCollection.CreateNewElement("add");
#addElement.Properties.Item("name").Value = "PHP-FastCGI";
[xml]$XmlDocument = Get-Content -Path $webpath
$handler = $XmlDocument.configuration.'system.webServer'.handlers.ChildNodes | Where-Object {$_.Name -eq 'CaptchaImage'}
if( $handler -eq $null )
@RobsonAutomator
RobsonAutomator / restoreDB.sql
Last active March 29, 2021 16:42
restore RDS database from S3
-- Change [bucket] with your bucket name
exec msdb.dbo.rds_restore_database
@restore_db_name='Sitecore_Analytics',
@s3_arn_to_restore_from='arn:aws:s3:::[bucket]/Sitecore_Analytics.bak';
exec msdb.dbo.rds_restore_database
@restore_db_name='Sitecore_Core',
@s3_arn_to_restore_from='arn:aws:s3:::[bucket]/Sitecore_Core.bak';
@RobsonAutomator
RobsonAutomator / powershell-help.ps1
Created December 27, 2016 19:06
powershell-help
<#
.SYNOPSIS
The synopsis goes here. This can be one line, or many.
.DESCRIPTION
The description is usually a longer, more detailed explanation of what the script or function does. Take as many lines as you need.
.PARAMETER computername
Here, the dotted keyword is followed by a single parameter name. Don't precede that with a hyphen. The following lines describe the purpose of the parameter:
@RobsonAutomator
RobsonAutomator / generate-logins-list.ps1
Last active January 4, 2017 15:24
Generate lists of login sites for Sitecore
Import-Module sitecore-automation -force
$AppConfig = "$AppPath\App_Config\Include\"
$hosts = Get-SitecoreSites -Path $AppConfig | Select-Object -ExpandProperty hostName | `
Show-ListView -Property @{Label="Login"; Expression={ "<a href='http://" + $_ + "/sitecore/login'>" + $_ + "</a>" } }
@RobsonAutomator
RobsonAutomator / add-bindings-and-hosts.ps1
Last active January 5, 2017 15:52
add-bindings-and-hosts
#https://bitbucket.org/sitecoreautomationteam/sitecore-automation/wiki/Home
#https://www.powershellgallery.com/packages/sitecore-automation/0.9
Import-Module sitecore-automation -force
# This file must exist
$devhosts = 'C:\Users\user\Desktop\dev.hosts'
# Path to config files
$webPath = 'E:\www\MyProject\Website\App_Config\Include\'
@RobsonAutomator
RobsonAutomator / switch-to-solr.ps1
Last active January 10, 2017 14:20
Switch Lucene to Solr
# Path to Sitecore root folder not website folder
$webPath = "B:\Sitecore 8.2 rev. 160729\"
$csvPath = "B:\Sitecore 8.2 rev. 160729\Website\App_Config\Config Enable-Disable Sitecore_8.2 Update1.csv"
# Use -WhatIf -Verbose options for the first time
Set-SitecoreEnvironment -WebPath $webPath -CsvPath $csvPath -Search Solr -Environment ContentManagement -Backup
@RobsonAutomator
RobsonAutomator / Set-UAC4SPE.ps1
Last active October 19, 2019 20:49
Set User Access Control for SPE
function Get-DefaultSpeConfig()
{
# $AppPath is SPE console variable, see Variables on https://doc.sitecorepowershell.com/interfaces.html
if( $AppPath -ne $null )
{
return Join-Path -Path $AppPath -ChildPath "App_Config\Include\Cognifide.PowerShell.config"
}
}
function Set-UAC4SPE
@RobsonAutomator
RobsonAutomator / export-custom-user-properties.ps1
Created February 3, 2017 22:20
export-custom-user-properties
$property = @(
@{Name='Email';Expression={ $PSItem.Profile.GetCustomProperty('Email') }},
@{Name='FirstName';Expression={ $PSItem.Profile.GetCustomProperty('FirstName') }},
@{Name='LastName';Expression={ $PSItem.Profile.GetCustomProperty('LastName') }},
@{Name='Title';Expression={ $PSItem.Profile.GetCustomProperty('Title') }},
@{Name='Company';Expression={ $PSItem.Profile.GetCustomProperty('Company') }},
@{Name='Country';Expression={ $PSItem.Profile.GetCustomProperty('Country') }},
@{Name='ZipCode';Expression={ $PSItem.Profile.GetCustomProperty('ZipCode') }},
@{Name='Department';Expression={ $PSItem.Profile.GetCustomProperty('Department') }},
@{Name='Street';Expression={ $PSItem.Profile.GetCustomProperty('Street') }},