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
michaellwest / UpdateExternalLink.ps1
Created Mar 29, 2020
Update external links to open in a new tab using Sitecore PowerShell Extensions.
View UpdateExternalLink.ps1
@michaellwest
michaellwest / RemoveSCTickets.ps1
Created Mar 29, 2020
Remove SC_TICKET entries from the Core database using Sitecore PowerShell Extensions.
View RemoveSCTickets.ps1
# https://kb.sitecore.net/articles/345947
Import-Function -Name Invoke-SqlCommand
$connection = [Sitecore.Configuration.Settings]::GetConnectionString("core")
$query = @"
DELETE TOP (100)
FROM [dbo].[Properties]
WHERE [Key] LIKE 'SC_TICKET_%'
@michaellwest
michaellwest / FindItemsWithSpecialCharacter.ps1
Created Mar 26, 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
#>
@michaellwest
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
<#
.SYNOPSIS
Lists all the items locked by the specified user.
.NOTES
Adam Najmanowicz, Michael West
#>
Import-Function -Name Invoke-SqlCommand
@michaellwest
michaellwest / SharePoint-AddSelectAll
Created Sep 25, 2019
Adds a select all option to a SharePoint list of checkboxes.
View SharePoint-AddSelectAll
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.js" 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) {
e.preventDefault();
statesTable.find('.ms-RadioText :checkbox').prop('checked', true);
});
$('<span>&nbsp;</span>').insertBefore(statesTable);
@michaellwest
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
UNION
SELECT [versionedfields].[itemid]
@michaellwest
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
michaellwest / Remove-Multiple-Sessions.ps1
Created Jul 15, 2019
Remove duplicate user sessions during login using Sitecore PowerShell Extensions. Solution for https://github.com/SitecoreSupport/Sitecore.Support.94909.
View Remove-Multiple-Sessions.ps1
# Solution for https://github.com/SitecoreSupport/Sitecore.Support.94909
# 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)"
You can’t perform that action at this time.