Skip to content

Instantly share code, notes, and snippets.

michaellwest / RemotelyDownloadImage.ps1
Last active Aug 29, 2015
The following downloads images from the media library in the master db and dynamically detects the file extension.
View RemotelyDownloadImage.ps1
# The following downloads an item from the media library in the master db and dynamically detects the file extension.
$session = New-ScriptSession -Username admin -Password b -ConnectionUri http://remotesitecore
Receive-MediaItem -Session $session -Path "/sitecore/media library/Images/Icons/accuracy" -Destination C:\Images\ -Force
michaellwest / RemotelyUploadImage.ps1
Created Jul 13, 2015
The following uploads images from the filesystem to the media library in the master db.
View RemotelyUploadImage.ps1
# The following uploads a single image with a new name to the specified path in the media library in the master db.
$session = New-ScriptSession -Username admin -Password b -ConnectionUri http://remotesitecore
Send-MediaItem -Session $session -Path C:\Images\banner.jpg -Destination "/sitecore/media library/Images/banner.jpg"
michaellwest / BaseTemplateReport.ps1
Last active Aug 29, 2015
Sitecore patch configuration to add _basetemplates to the default Lucene index. Includes sample report.
View BaseTemplateReport.ps1
$props = @{
Parameters = @(
@{ Name="Info"; Title="Index"; Value="The report will be based on $($index)."; editor="info" },
Title="Base Template"
Tooltip="Index the _basetemplates field as shown here on <a href='' target='_blank'>Github</a>."
michaellwest / ListRunningAppPools.ps1
Created Jul 25, 2015
The following lists all application pools in IIS and matches with their associated w3wp.exe process id.
View ListRunningAppPools.ps1
Import-Module -Name WebAdministration
$appPoolsPath = "IIS:\AppPools"
foreach($appPool in Get-ChildItem -Path $appPoolsPath) {
if($appPool.state -eq "Started") {
$processes = Get-ChildItem -Path "$($appPoolsPath)\$($appPool.Name)\WorkerProcesses"
foreach($process in $processes) {
"AppPool" = $appPool.Name
michaellwest / MeasureCommandPerformance.ps1
Created Aug 8, 2015
Measure PowerShell command performance in SPE.
View MeasureCommandPerformance.ps1
$path = "master:\"
$identity = "admin"
$time1 = Measure-Command -Expression {
Get-ChildItem -Path $path -Recurse | Where-Object { $_.__lock -eq $identity }
$time2 = Measure-Command -Expression {
$query = "fast://*[@__lock='%$($identity)%']"
Get-Item -Path $Path -Query $query
michaellwest / GetSitecoreMarketplaceModulesList.ps1
Created Sep 3, 2015
The script pulls the latest list of Sitecore Marketplace modules, including the release and revision dates.
View GetSitecoreMarketplaceModulesList.ps1
$VerbosePreference = "Continue"
$relpattern = "(<label>Release date:</label>\s*<span.*>(?<release>[0-9/:AMP\s]*)</span>)"
$revpattern = "(<label>Revision date:</label>\s*<span.*>(?<revision>[0-9/:AMP\s]*)</span>)"
function Get-PageContent {
michaellwest / SmartPublishItems.ps1
Created Sep 12, 2015
Adapted the functions written by Nick Wesselman to work directly in SPE.
View SmartPublishItems.ps1
Copied from Nick Wesselman's video
function Start-Publish {
[string]$Source = "master",
[string]$Target = "web"
michaellwest / Report-Content.ps1
Created Nov 24, 2015
Generates a report with all Sitecore content items, excluding specific template ids.
View Report-Content.ps1
Queries all pages on the site, excluding non-content items.
# List of template ids to exclude from the count.
$templateIds = @(
michaellwest / RemoveGAEventHandler.ps1
Created Nov 24, 2015
Replaces all instances of the Google Analytics click event with an empty string.
View RemoveGAEventHandler.ps1
$path = "master:\content\"
$items = Get-ChildItem -Path $path -Recurse
$fields = @("Ads","Body","Carousel","HtmlText","Left Body","Location Body","Mid Body","Quick Links and News","Search Location")
$updateCounts = @{}
$fields | ForEach-Object { $updateCounts[$_] = 0 }
foreach($item in $items) {
Write-Host "Processing $($item.Id) : $($item.Name)"
foreach($field in $fields) {
if($item.$field) {
michaellwest / TraceBinding.ps1
Created Nov 26, 2015
Trace PowerShell parameter binding.
View TraceBinding.ps1
Trace-Command -Name ParameterBinding -PSHost -Expression {
Get-Item -Path "master:\content\home"