Skip to content

Instantly share code, notes, and snippets.

Wesley Lomax Wesley-Lomax

Block or report user

Report or block Wesley-Lomax

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
@Wesley-Lomax
Wesley-Lomax / ListAllItemsWithAClone.ps1
Created Jun 20, 2019
Lists all items in a Sitecore branch with a clone
View ListAllItemsWithAClone.ps1
# HasTooManyRenderings determines if the specified item has more than the specified number of renderings.
$startItem = Get-Item -Path master:\content\
$resultsPageSize = 30
$props = @{
Title = "Find item clones"
Description = "This report will analyse the branch and will tell you which items clones ."
Width = 450
Height = 300
@Wesley-Lomax
Wesley-Lomax / FindHighRenderings.ps1
Last active Jun 14, 2019
Find Sitecore items with renderings greater than provided parameter
View FindHighRenderings.ps1
# HasTooManyRenderings determines if the specified item has more than the specified number of renderings.
$startItem = Get-Item -Path master:\content\
$maxRenderings = 30
$resultsPageSize = 30
$props = @{
Title = "Count renderings on items"
Description = "This report will analyse the branch and will tell you which items have a renderings count greater than the provided parameters ."
Width = 450
@Wesley-Lomax
Wesley-Lomax / CountComponents.ps1
Created Jun 13, 2019
Get count of Sitecore components on layout / page
View CountComponents.ps1
$item = gi "/sitecore/content/Habitat Sites/Habitat Home/home" -Language 'en'
$sharedLayoutField = $item.Fields[[Sitecore.FieldIDs]::LayoutField]
$finalLayoutField = $item.Fields[[Sitecore.FieldIDs]::FinalLayoutField]
$sharedLayoutXml = [Sitecore.Data.Fields.LayoutField]::GetFieldValue($sharedLayoutField)
$finalLayoutXml = [Sitecore.Data.Fields.LayoutField]::GetFieldValue($finalLayoutField)
$sharedLayout = [Sitecore.Layouts.LayoutDefinition]::Parse($sharedLayoutXml)
$finalLayout = [Sitecore.Layouts.LayoutDefinition]::Parse($finalLayoutXml)
@Wesley-Lomax
Wesley-Lomax / Sitecore.Debug.LoggingLevel.config
Created May 7, 2019
Sitecore Logging Level Patch Config
View Sitecore.Debug.LoggingLevel.config
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/">
<sitecore>
<log4net>
<root>
<priority set:value="DEBUG" />
</root>
</log4net>
</sitecore>
</configuration>
@Wesley-Lomax
Wesley-Lomax / web-request-loop.ps1
Created Jun 26, 2018
Fire web request at server with loop
View web-request-loop.ps1
$targetSite = "https://hostname"
Write-Host "Requesting " $targetSite
while($true)
{
Invoke-WebRequest -TimeoutSec 120 -method head -Uri $targetSite | Select-Object StatusCode, StatusDescription
Start-Sleep -Seconds 60
}
@Wesley-Lomax
Wesley-Lomax / CreateSitecorePackageOfPageAndAllItems.ps1
Last active Apr 19, 2018
Creates a Sitecore package for an item include the item, its templates and base templates, renderings and their datasource items and templates.
View CreateSitecorePackageOfPageAndAllItems.ps1
function AddItemToCollection($itemId)
{
$itemCollection.Add($itemId)
}
function GetRenderings()
{
Get-Rendering -Item $startItem -FinalLayout | Foreach-Object {
if($_.ItemID)
@Wesley-Lomax
Wesley-Lomax / CountItemsMatchingTemplateInTree.ps1
Created Mar 23, 2018
Get Count of all Sitecore Items in list of templates in content tree
View CountItemsMatchingTemplateInTree.ps1
<#
SYNOPSIS
Does a simple count of all items in the specified templates
INSTRUCTIONS
After Get-Item -Path, type the path of the parent you want to start with.
EX: master:\sitecore\content\sites\example
Put the same path after Get-ChildItem, which will crawl through and find all child pages.
It'll display the number
@Wesley-Lomax
Wesley-Lomax / GetItemsWhereTemplateMatches.ps1
Last active Mar 23, 2018
List all Sitecore items where template is in a predefined list and location in the content tree, display in ListView
View GetItemsWhereTemplateMatches.ps1
<#
SYNOPSIS
Does a simple count of all items in the specified templates
INSTRUCTIONS
After Get-Item -Path, type the path of the parent you want to start with.
EX: master:\sitecore\content\sites\example
Put the same path after Get-ChildItem, which will crawl through and find all child pages.
#>
@Wesley-Lomax
Wesley-Lomax / ClearSitecoreLogsDirectory.ps1
Created Aug 24, 2017
Delete Sitecore Log File Directory - Local Dev
View ClearSitecoreLogsDirectory.ps1
gci C:\inetpub\wwwroot\RCN\Data\logs -Recurse -Filter *.txt | where{-not $_.PsIsContainer}| sort CreationTime -desc| select -Skip 0 | Remove-Item -Force
@Wesley-Lomax
Wesley-Lomax / HTTPResponseCodeStep.json
Created Jul 31, 2017
Octopus Depoy - Check for HTTP Response Code
View HTTPResponseCodeStep.json
{
"Id": "ActionTemplates-3",
"Name": "HTTP - Test URL",
"Description": "Makes a GET request to a HTTP(S) end point and verifies that a particular status code is returned within a specified period of time",
"ActionType": "Octopus.Script",
"Version": 1,
"Properties": {
"Octopus.Action.Script.ScriptBody": "$uri = $OctopusParameters['Uri']\n$expectedCode = [int] $OctopusParameters['ExpectedCode']\n$timeoutSeconds = [int] $OctopusParameters['TimeoutSeconds']\n$Username = $OctopusParameters['AuthUsername']\n$Password = $OctopusParameters['AuthPassword']\n$UseWindowsAuth = $OctopusParameters['UseWindowsAuth']\n\nWrite-Host \"Starting verification request to $uri\"\nWrite-Host \"Expecting response code $expectedCode.\"\n\n$timer = [System.Diagnostics.Stopwatch]::StartNew()\n$success = $false\ndo\n{\n try\n {\n if ($Username -and $Password -and $UseWindowsAuth)\n\t\t\t{\n\t\t\t Write-Host \"Making request to $uri using windows authentication for user $Username\"\n\t\t\t $request = [s
You can’t perform that action at this time.