Skip to content

Instantly share code, notes, and snippets.

View RobsonAutomator's full-sized avatar

Ro Se RobsonAutomator

View GitHub Profile
@RobsonAutomator
RobsonAutomator / fix-size-field-in-media-items.ps
Last active March 11, 2020 15:30
Update value in the Size field in Sitecore media items.
#
# 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 February 7, 2020 16:25
Convers a Sitecore Powershell Extension item to a file on disk.
function Convert-ScriptItemToFile {
<#
.SYNOPSIS
Convers a SPE item to a file on disk.
.NOTES
Autor: Robert Senktas (@RobsonAutomator)
#>
@RobsonAutomator
RobsonAutomator / set-contentdefaultlanguage.ps1
Created December 13, 2019 14:39
Setup default content language in Sitecore for Content Author
# 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 July 12, 2019 13:31
Performance tests for create a zip archive with PowerShell
$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 July 12, 2019 11:30
Performance test for expand ZIP archive
$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 March 14, 2019 08:26
Show Sitecore Config - can be useful for CD servers
@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 December 6, 2018 11:11
Copy items from source to destination
$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 February 15, 2018 15:31
Bulk update Sitecore license
#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 January 18, 2018 14:04
Sitecore Install Framework requirements
#requires -RunAsAdministrator
#requires -Version 5.1
#requires -module SitecoreInstallFramework
#requires -module SitecoreInstallExtensions
@RobsonAutomator
RobsonAutomator / Install-Sitecore8.ps1
Last active January 14, 2018 20:12
Install Sitecore8 and prerequisites with Sitecore Install Framework and Sitecore Install Extensions
#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"