Skip to content

Instantly share code, notes, and snippets.

Avatar

Ro Se RobsonAutomator

View GitHub Profile
@RobsonAutomator
RobsonAutomator / fix-size-field-in-media-items.ps
Last active Mar 11, 2020
Update value in the Size field in Sitecore media items.
View fix-size-field-in-media-items.ps
#
# Fix value '123 x 123' in Size field to the proper image size (bytes).
# Author: Robert Senktas
#
$sitecorePath = "master:/sitecore/media library"
$processedItems = Get-ChildItem -Path $sitecorePath -Recurse | ForEach-Object {
if ( $_.Size -match "x" ) {
$mediaItem = New-Object "Sitecore.Data.Items.MediaItem" $_
@RobsonAutomator
RobsonAutomator / Convert-ScriptItemToFile.ps1
Created Feb 7, 2020
Convers a Sitecore Powershell Extension item to a file on disk.
View Convert-ScriptItemToFile.ps1
function Convert-ScriptItemToFile {
<#
.SYNOPSIS
Convers a SPE item to a file on disk.
.NOTES
Autor: Robert Senktas (@RobsonAutomator)
#>
@RobsonAutomator
RobsonAutomator / set-contentdefaultlanguage.ps1
Created Dec 13, 2019
Setup default content language in Sitecore for Content Author
View set-contentdefaultlanguage.ps1
# Author: Robert Senktas vel @RobsonAutomator
# Scritp to use with Sitecore PowerShell Extension
$user = Get-User -Identity $me -Authenticated
$options = [ordered]@{};
$languages = Get-ChildItem -Path 'master:/sitecore/system/Languages/'
foreach( $language in $languages )
{
$options.Add($language.Name, $language.Name);
@RobsonAutomator
RobsonAutomator / create-zip-performance-tests.ps1
Created Jul 12, 2019
Performance tests for create a zip archive with PowerShell
View create-zip-performance-tests.ps1
$archivePath = "E:\Test"
$folderToArchive = "E:\Temp\FolderToCompress"
# prepare output folder
mkdir $archivePath -Force
Clear-Host
for( $i = 0; $i -lt 10; $i++ )
{
$measureExtract = Measure-Command {
@RobsonAutomator
RobsonAutomator / expand-zip-performance.ps1
Last active Jul 12, 2019
Performance test for expand ZIP archive
View expand-zip-performance.ps1
$archivePath = "C:\test80MB.zip"
$destinationFolder = "D:\Test"
mkdir $destinationFolder -Force
Clear-Host
for( $i = 0; $i -lt 10; $i++ )
{
$measureExpand = Measure-Command {
@RobsonAutomator
RobsonAutomator / showconfig.cshtml
Last active Mar 14, 2019
Show Sitecore Config - can be useful for CD servers
View showconfig.cshtml
@using Sitecore.Configuration
<!-- Author: Robert Senktas vel RobsonAutomator -->
<!-- Remove this file from server after usage -->
<!-- http://<hostname>/showconfig.cshtml?save=true saves xml to the App_Data folder -->
@{
if (!Context.Request.IsLocal)
{
Response.StatusCode = 404;
return;
}
@RobsonAutomator
RobsonAutomator / copy-items.ps1
Created Dec 6, 2018
Copy items from source to destination
View copy-items.ps1
$destination = 'master:\sitecore\templates\'
$source = 'master:\sitecore\templates\'
$items = Get-ChildItem -Path $source
#use -WhatIf to check
Get-ChildItem -Path $destination | Remove-Item
foreach( $item in $items )
{
Copy-Item $item.ItemPath $destination
@RobsonAutomator
RobsonAutomator / update-license.ps1
Created Feb 15, 2018
Bulk update Sitecore license
View update-license.ps1
#requires -RunAsAdministrator
# Update all licenses
# You can find more about automation with Powershell on http://lets-share.senktas.net
$iisRoot = "C:\inetpub\wwwroot"
$licenseFile = "C:\license.xml"
(Get-ChildItem -Path $iisRoot -Filter 'license.xml' -Recurse).DirectoryName | % { Copy-Item -Path $licenseFile -Destination $_ -Verbose}
@RobsonAutomator
RobsonAutomator / sif-requirement.ps1
Created Jan 18, 2018
Sitecore Install Framework requirements
View sif-requirement.ps1
#requires -RunAsAdministrator
#requires -Version 5.1
#requires -module SitecoreInstallFramework
#requires -module SitecoreInstallExtensions
@RobsonAutomator
RobsonAutomator / Install-Sitecore8.ps1
Last active Jan 14, 2018
Install Sitecore8 and prerequisites with Sitecore Install Framework and Sitecore Install Extensions
View Install-Sitecore8.ps1
#requires -RunAsAdministrator
#requires -Version 5.1
#requires -module SitecoreInstallFramework
#requires -module SitecoreInstallExtensions
#SIF will install SitecoreInstallExtension; we haven't to import module explicit
Import-Module SitecoreInstallFramework
$folderRoot = "C:\Users\Administrator\Downloads"