Skip to content

Instantly share code, notes, and snippets.

View patelcp's full-sized avatar

Chirag Patel patelcp

View GitHub Profile
@patelcp
patelcp / ExcludeStandardFields.ps1
Created January 9, 2022 22:06 — forked from michaellwest/ExcludeStandardFields.ps1
Find the fields used by a template, excluding the standard template fields in Sitecore PowerShell Extensions.
# Create a list of field names on the Standard Template. This will help us filter out extraneous fields.
$standardTemplate = Get-Item -Path "master:" -ID ([Sitecore.TemplateIDs]::StandardTemplate.ToString())
$standardTemplateTemplateItem = [Sitecore.Data.Items.TemplateItem]$standardTemplate
$standardFields = $standardTemplateTemplateItem.OwnFields + $standardTemplateTemplateItem.Fields | Select-Object -ExpandProperty key -Unique
# Change the Id to something other than the Sample Item template.
$itemTemplate = Get-Item -Path "master:" -ID "{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}"
$itemTemplateTemplateItem = [Sitecore.Data.Items.TemplateItem]$itemTemplate
$itemTemplateFields = $itemTemplateTemplateItem.OwnFields + $itemTemplateTemplateItem.Fields | Select-Object -ExpandProperty key -Unique
@patelcp
patelcp / TemplateFieldsReport.ps1
Created June 22, 2021 16:31
Sitecore PowerShell Module - Reporting
$TemplateID = "{guid}"
# Create a list of field names on the Standard Template. This will help us filter out extraneous fields.
$standardTemplate = Get-Item -Path "master:" -ID ([Sitecore.TemplateIDs]::StandardTemplate.ToString())
$standardTemplateTemplateItem = [Sitecore.Data.Items.TemplateItem]$standardTemplate
$standardFields = $standardTemplateTemplateItem.OwnFields + $standardTemplateTemplateItem.Fields | Select-Object -ExpandProperty key -Unique
# Change the Id to something other than the Sample Item template.
$itemTemplate = Get-Item -Path "master:" -ID $TemplateID
$itemTemplateTemplateItem = [Sitecore.Data.Items.TemplateItem]$itemTemplate
@patelcp
patelcp / Update workflow and state of content items.ps1
Created June 5, 2021 13:09 — forked from marcduiker/Update workflow and state of content items.ps1
Sitecore PowerShell script that creates a report listing content items which has no workflow set while their templates have the Default workflow field set.
<#
.SYNOPSIS
Update Workflow and Workflow state of content items which have no workflow set while their templates have the Default workflow field set.
.DESCRIPTION
This script can be used when existing content is not assigned to a workflow and workflow state while it should be.
This scenario usually occurs when a workflow is assigned to a template but there is already content created based on a previous version of that template (where the workflow was not yet assigned).
@patelcp
patelcp / Test-SitecoreAssemblyList.ps1
Created December 29, 2017 21:48 — forked from richardszalay/Test-SitecoreAssemblyList.ps1
Test-SitecoreAssemblyList.ps1
<#
.SYNOPSIS
Validates a Sitecore "Assembly list" (from dev.sitecore.net) against a folder
.PARAMETER AssemblyList
The assembly list text file downloaded from dev.sitecore.net
.PARAMETER AssemblyFolder
The folder containing the Sitecore assemblies to validate
.PARAMETER CheckFileVersion
If set, also verifies the file version. Requires loading the assembly, so should be invoked in an isolated powershell environment
.NOTES
@patelcp
patelcp / Clean up databases.ps1
Created December 29, 2017 21:44 — forked from michaellwest/Clean up databases.ps1
Run Sitecore rebuild and clean up tasks
<#
.SYNOPSIS
Runs a clean up for each database.
.NOTES
Michael West
#>
foreach($database in Get-Database) {
if(!$database.ReadOnly) {
@patelcp
patelcp / Create Anti-Package.ps1
Created December 29, 2017 21:42 — forked from michaellwest/Create Anti-Package.ps1
Generates an anti-package from the selected package. Requires SPE 3.1.
$response = Show-ModalDialog -HandleParameters @{
"h"="Create an Anti-Package";
"t" = "Select a package that needs an anti-package";
"ic"="People/16x16/box.png";
"ok"="Pick";
"ask"="";
"path"= "packPath:$SitecorePackageFolder";
"mask"="*.zip";
} -Control "Installer.Browse"
@patelcp
patelcp / Update workflow for all items.ps1
Created December 29, 2017 21:37 — forked from marcduiker/Update workflow for all items.ps1
Sitecore PowerShell action to update the workflow and workflow state for all items in the ListView of the report.
$processedItems = New-Object System.Collections.ArrayList
function SetWorkFlowAndState {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true)]
[Sitecore.Data.Items.Item]$Item,
[Parameter(Mandatory=$true)]
[Sitecore.Data.ID]$WorkflowID,
[Parameter(Mandatory=$true)]
@patelcp
patelcp / FindAndDownloadRecentChangeList.ps1
Created December 29, 2017 21:36 — forked from michaellwest/FindAndDownloadRecentChangeList.ps1
Queries a list of items that have been modified after a certain date. Generates a CSV and downloads from the server.
$startDate = [datetime]"02/24/2016"
$days = ([datetime]::today - $startDate).Days
Get-ChildItem master:\content\home -Recurse |
? { $_."__updated" -gt (Get-Date).AddDays(-$days) } |
Where-Object { "Resource Reference","Sitemap","AddOns","Market Generic Page" -notcontains $_.TemplateName } |
Select-Object -Property ID, Name, "__updated", "__updated by", "TemplateName" |
Export-Csv -Path "$($SitecoreDataFolder)\page-changes.csv"
@patelcp
patelcp / RemotelyDownloadFile.ps1
Created December 29, 2017 21:27 — forked from michaellwest/RemotelyDownloadFile.ps1
Read all bytes of a file from the Sitecore PowerShell Extensions remoting service.
Import-Module -Name SPE
$session = New-ScriptSession -Username admin -Password b -ConnectionUri http://console
$bytes = Invoke-RemoteScript -Session $session -ScriptBlock {
[System.IO.File]::ReadAllBytes("$($SitecoreDataFolder)packages\SPE Remoting-3.1.zip")
}
[System.IO.File]::WriteAllBytes("C:\temp\SPE Remoting-3.1.zip", $bytes)
@patelcp
patelcp / RebuildSearchIndexesWithProgress.ps1
Created December 29, 2017 21:27 — forked from michaellwest/RebuildSearchIndexesWithProgress.ps1
Rebuild all of the Sitecore content search indexes with a progress dialog.
Get-SearchIndex | Rebuild-SearchIndex -IncludeRemoteIndex
$jobs = [Sitecore.Jobs.JobManager]::GetJobs() | Where-Object { !$_.IsDone -and $_.Category -eq "Indexing" } | Sort-Object -Property Name
$jobsCount = $jobs.Count
while(($jobs | Where-Object { !$_.IsDone })) {
$progressCount = 0
$message = New-Object System.Text.StringBuilder
foreach($job in $jobs) {
$message.AppendLine("$($job.Name) is $($job.Status.State) and processed: $($job.Status.Processed)") | Out-Null