Skip to content

Instantly share code, notes, and snippets.

Michael michaellwest

  • Texas
Block or report user

Report or block michaellwest

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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
Convert a PrivateKey from the certificate store into a PKCS8 formatted file.
Found C# version here
Michael West
michaellwest / FindLockedItemsInTheDatabase-Report.ps1
Last active Oct 22, 2019
Find locked items by user using Sitecore PowerShell Extensions. This takes into account which language and version of the items are locked.
View FindLockedItemsInTheDatabase-Report.ps1
Lists all the items locked by the specified user.
Adam Najmanowicz, Michael West
Import-Function -Name Invoke-SqlCommand
michaellwest / SharePoint-AddSelectAll
Created Sep 25, 2019
Adds a select all option to a SharePoint list of checkboxes.
View SharePoint-AddSelectAll
<script src="" integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" crossorigin="anonymous"></script>
<script type="text/javascript">
$(function() {
var statesTable = $('table[id^="State"');
var selectAll = $('<a href="#" id="select-all-states">Select All</a>').insertBefore(statesTable);
selectAll.on('click', function(e) {
statesTable.find('.ms-RadioText :checkbox').prop('checked', true);
michaellwest / CleanupBlobData.sql
Created Sep 24, 2019
Cleanup orphaned blob data using SSMS. When Sitecore runs this process it may timeout otherwise.
View CleanupBlobData.sql
DECLARE @BlobID uniqueidentifier;
SELECT @BlobID = '{FF8A2D01-8A77-4F1B-A966-65806993CD31}';
WITH [BlobFields] ([fieldid])
AS (SELECT [sharedfields].[itemid]
FROM [sharedfields]
WHERE [sharedfields].[fieldid] = @BlobID
AND [sharedfields].[value] = 1
SELECT [versionedfields].[itemid]
michaellwest / SitecoreRenderingStats.ps1
Created Sep 10, 2019
Duplicates the functionality seen in the Sitecore stats.aspx admin page using Sitecore PowerShell Extensions.
View SitecoreRenderingStats.ps1
$items = [Sitecore.Diagnostics.Statistics]::RenderingStatistics
$props = @{
Property = @(
@{Label="Rendering"; Expression={$_.TraceName} },
@{Label="Site"; Expression={$_.SiteName} },
@{Label="Count"; Expression={$_.RenderCount} },
@{Label="From cache"; Expression={$_.UsedCache} },
@{Label="Avg. time (ms)"; Expression={$_.AverageTime.TotalMilliseconds} },
@{Label="Avg. items"; Expression={$_.AverageItemsAccessed} },
@{Label="Max. time"; Expression={$_.MaxTime.TotalMilliseconds} },
michaellwest / Remove-Multiple-Sessions.ps1
Created Jul 15, 2019
Remove duplicate user sessions during login using Sitecore PowerShell Extensions. Solution for
View Remove-Multiple-Sessions.ps1
# Solution for
# Cannot login in Sitecore CMS due to multiple same users already logged in
# Saved to /sitecore/system/Modules/PowerShell/Script Library/[CUSTOM_MODULE_NAME]/Pipelines/LoggedIn/Remove Multiple Sessions
$pipelineArgs = Get-Variable -Name pipelineArgs -ValueOnly
$username = $pipelineArgs.UserName
if(!$username) { return }
$sessionId = [System.Web.HttpContext]::Current.Session.SessionID
Write-Log "The current session Id is $($sessionId) for user $($username)"
michaellwest / Report-Template-Sources-Faster.ps1
Last active Jul 11, 2019
Find all template fields where the source is not empty using Sitecore PowerShell Extensions.
View Report-Template-Sources-Faster.ps1
$watch = [System.Diagnostics.Stopwatch]::StartNew()
$path = "/sitecore/templates/Project"
$templateId = "{AB86861A-6030-46C5-B394-E8F99E8B87DB}"
$templateFieldId = "{455A3E98-A627-4B40-8035-E683A0331AC7}"
$db = Get-Database -Name "master"
$rootItem = $db.GetItem($path)
$templates = $rootItem.Axes.GetDescendants() |
Where-Object { $_.TemplateId -eq $templateId } | Initialize-Item
michaellwest / Update-AltTags.ps1
Created Jul 5, 2019
Update image alt tags using Sitecore PowerShell Extensions.
View Update-AltTags.ps1
$rootPath = "/content/Company/DotCom/usa/home"
$file = "$($SitecoreDataFolder)\temp\alt-tags.csv"
$records = Import-Csv -Path $file
$totalCount = $records.Count
$currentCount = 0
$activity = "Updating alt tags"
foreach($record in $records) {
$currentCount += 1
$percentComplete = $currentCount / $totalCount * 100
$itemPath = $rootPath + ($record.Url -replace "","")
michaellwest / New-DesktopShortcut.ps1
Last active Jun 20, 2019
Add a new Sitecore Desktop shortcut with Sitecore PowerShell Extensions.
View New-DesktopShortcut.ps1
class DesktopLink {
$fields = @()
$fields += [System.Web.HttpUtility]::UrlEncode($this.DatabaseName)
michaellwest / Get-ItemUrl.ps1
Created Feb 13, 2019
Generate an item url given an item and the sitecontext using Sitecore PowerShell Extensions.
View Get-ItemUrl.ps1
function Get-ItemUrl {
$result = New-UsingBlock(New-Object Sitecore.Sites.SiteContextSwitcher $siteContext) {
New-UsingBlock(New-Object Sitecore.Data.DatabaseSwitcher $item.Database) {
You can’t perform that action at this time.