Skip to content

Instantly share code, notes, and snippets.

Michael michaellwest

  • Texas
View GitHub Profile
@michaellwest
michaellwest / GenerateFormsReport.ps1
Last active Jun 27, 2020
Generate a report of forms data using Sitecore PowerShell Extensions.
View GenerateFormsReport.ps1
$selectedForm = Get-Item -Path "master:" -ID ([Sitecore.ExperienceForms.Client.Constants.GeneralConstants]::FormsFolderId)
$props = @{
Parameters = @(
@{Name="selectedForm"; Value=$null; Title="Choose a form to filter out the results"; Tooltip=""; Editor="treelist"; Source="DataSource=$($selectedForm.ItemPath)&DatabaseName=master&IncludeTemplatesForDisplay=Folder,Form&IncludeTemplatesForSelection=Form"; },
@{ Name = "startDate"; Value=[System.DateTime]::Now.AddDays(-30); Title="Start Date"; Tooltip="Earliest submitted entries to return"; Editor="date"; Columns=6; },
@{ Name = "endDate"; Value=[System.DateTime]::Now; Title="End Date"; Tooltip="Latest submitted entries to return"; Editor="date"; Columns=6; }
)
Title = "Forms Report"
@michaellwest
michaellwest / CopyGeoFieldData.ps1
Last active Jun 29, 2020
Tips for upgrading Sitecore using SXA and Scriban
View CopyGeoFieldData.ps1
# First make your items inherit from /sitecore/templates/System/Geospatial/Coordinate
# Leave the existing IPoi there until after Go Live otherwise the data will be lost (or you have to run the import again)
# TODO : Update the import script to use the new field
# Change to the root ID for items which use the IPoi template
# Careers
#$rootId = "{B8208D4B-C25E-4381-A183-4177E47A9310}"
# POIs
$rootId = "{60365D59-F2F2-4C49-91DA-9C7B046178CF}"
@michaellwest
michaellwest / Find-Renderings-With-Rules.ps1
Created May 24, 2020
Find home items where a rendering has 1 or more rules applied using Sitecore PowerShell Extensions.
View Find-Renderings-With-Rules.ps1
$device = Get-LayoutDevice -Default
$sites = [Sitecore.Configuration.Factory]::GetSiteInfoList()
foreach($site in $sites) {
$isTrackingEnabled = [Sitecore.MainUtil]::GetBool($site.Properties["enableTracking"], $true)
if($isTrackingEnabled -or [string]::IsNullOrEmpty($site.TargetHostName)) { continue }
$homeItem = Get-Item -Path "$($site.RootPath)/$($site.StartItem)".Replace("/sitecore", "master:")
Write-Host "Checking $($homeItem.ItemPath)"
foreach($rendering in $homeItem.Visualization.GetRenderings($device, $false)) {
if($rendering.Settings.Rules.Count -le 0) { continue }
$rendering
@michaellwest
michaellwest / ReadExif.ps1
Created May 16, 2020
Read EXIF orientation using Sitecore PowerShell Extensions.
View ReadExif.ps1
# https://exiftool.org/TagNames/EXIF.html
# https://stackoverflow.com/questions/27835064/get-image-orientation-and-rotate-as-per-orientation
# http://fredericiana.com/2013/05/23/imagetwist-exif-rotation-addon/
# https://www.cyotek.com/blog/handling-the-orientation-exif-tag-in-images-using-csharp
enum ExifOrientation {
RotateNoneFlipNone = 1
Rotate90FlipX = 5
Rotate90FlipNone = 6
}
#[System.Drawing.RotateFlipType]::Rotate90FlipNone
@michaellwest
michaellwest / FindDuplicateItemNames.ps1
Last active Apr 13, 2020
Find items with a duplicate item name at the same level using Sitecore PowerShell Extensions.
View FindDuplicateItemNames.ps1
Import-Function -Name Invoke-SqlCommand
$connection = [Sitecore.Configuration.Settings]::GetConnectionString("master")
$query = @"
SELECT
a.[ID],
a.[Name],
a.[ParentID]
FROM [dbo].[Items] a
@michaellwest
michaellwest / UpdateExternalLink.ps1
Last active Apr 13, 2020
Update external links to open in a new tab using Sitecore PowerShell Extensions.
View UpdateExternalLink.ps1
@michaellwest
michaellwest / CleanupTickets.ps1
Last active Apr 27, 2020
Remove SC_TICKET entries from the Core database using Sitecore PowerShell Extensions.
View CleanupTickets.ps1
<#
.SYNOPSIS
There is an issue with the authentication ticket cleanup for certain versions of Sitecore. Run this script as a scheduled task.
.LINK
https://kb.sitecore.net/articles/615926
$ticketIds = [Sitecore.Web.Authentication.TicketManager]::GetTicketIDs() |
ForEach-Object { $_.Replace("_", "") }
@michaellwest
michaellwest / FindItemsWithSpecialCharacter.ps1
Last active Mar 30, 2020
Finds items in the database with a special character using Sitecore PowerShell Extensions.
View FindItemsWithSpecialCharacter.ps1
Import-Function -Name Invoke-SqlCommand
$connection = [Sitecore.Configuration.Settings]::GetConnectionString("master")
$text = '%' + 'Ã' + '%'
$query = @"
select [ItemID], [FieldID], LEN([Value]) AS [FieldLength] from [SharedFields] WITH (NOLOCK) where [Value] like @0
"@
$shared = Invoke-SqlCommand -Connection $connection -Query $query -Parameters @{"@0"=$text}
$query = @"
@michaellwest
michaellwest / Validate-GeneralLink.ps1
Created Mar 20, 2020
Validate the xml stored in a GeneralLink field using Sitecore PowerShell Extensions.
View Validate-GeneralLink.ps1
@michaellwest
michaellwest / RSAKeyTools.ps1
Last active Jan 6, 2020
Convert the certificate private key to a PKCS8 formatted file. Made use of this for Traefik.
View RSAKeyTools.ps1
<#
.SYNPOSIS
Convert a PrivateKey from the certificate store into a PKCS8 formatted file.
.LINK
Found C# version here https://gist.github.com/chenrui1988/6b104a010172786dbcbc0aafc466d291/
.NOTES
Michael West
#>
You can’t perform that action at this time.