Posts

Showing posts with the label Sitecore powershell

PowerShell Script to update Alt tag missing for Images

Hello everyone. I am back with another powershell script that can be very useful if you want to update alt tag missing for all images in sitecore.We all know, how important is alt tag from SEO perspective and that's why, this powershell script can come very handy when we have lot of missing alt tag for images. Below is the powershell script for your reference.The script is pretty simple to understand. $rootPathOfImages = "/sitecore/media library/Project/" $testMode = $false $secondsToWaitOnLimitError = 60 $successCount = 0 $errorCount = 0 $errorList = "" $date = Get-Date $formattedDate =$date.tostring('dd-mmm-yyyy-hhmmss') # List of template ids to exclude from processing $excludedTemplateIds = @( "{FE5DD826-48C6-436D-B87A-7C4210C7413B}", #media folder "{0603F166-35B8-469F-8123-E8D87BEDC171}", #pdf "{16692733-9A61-45E6-B0D4-4C0C06F8DD3C}", #doc "{7BB0411F-50CD-4C21-AD8F-1FCDE7C3AFFE}", #...

Creating Custom Interactive Dialog to execute Sitecore PowerShell Script

Image
Hello everyone, we will try to learn how we can create a interactive dialog in Sitecore to execute powershell script. In this article we will see how we can convert a view rendering or controller rendering to JSON rendering via powershell interactive dialog. We will also check that how we will be adding the button to Ribbon in Sitecore. We will divide the blog into 3 section. Creating a Execute Button in Ribbon PowerShell Script to create interactive Dialog Demo of Script Step 1: Navigate to Script Library under PowerShell under Modules. Path : /sitecore/system/Modules/PowerShell/Script Library. Step 2: Right click Script Library --> Insert --> PowerShell Script Module --> Give A Name(CustomPowershell2) --> Ok Step 3: Right Powershell Script Module which is created --> Insert --> PowerShell Script Library --> Give A Name(Content Editor) --> Ok Step 4: Now create the content tree structure which...

Some Useful Sitecore PowerShell Script Part 2

Hello Everyone, this is my continuation for Part1 where we have seem some powershell script which can be handy during our Sitecore development. In this part we will see some powershell script which can be useful to us. Powershell script to find the all the link referrers of an item. Item path: Path of the item for which we need to find the where it is being getting used. #Getting Item referrer $props = @{ InfoTitle = "Referrers" InfoDescription = "Lists all items that are using this item" PageSize = 25 } function Get-ItemReferrers { $item = Get-Item -Path "{{Item path}}" $linkDb = [Sitecore.Globals]::LinkDatabase $links = $linkDb.GetReferrers($item) foreach($link in $links){ $linkedItem = Get-Item -Path master:\ -ID $link.SourceItemID $linkedItem } } $items = Get-ItemReferrers $items | Show-ListView @props -Property @{Label="Name"; Expression={$_.DisplayName} }, @{Label="Path...

Some Useful Sitecore Powershell Scripts Part 1

Hello Everyone. As we all know, when we work with Sitecore, there are many situation where we need to use powershell scripts. It can be for bulk item creation or item modification. In this blog, we will see some useful powershell script Creating Bulk Items in Sitecore from one data folder to another.In this example we are creating Country items for example Destination Path (Where item is going to be created) Source Item Path (From where item is going to be fetch) Template to be used : The template path from which item will be created. $destinationPath = "{{Destination Path}}" $countryItems = Get-ChildItem -Path "{{Source Item Path}}" $bulk = New-Object "Sitecore.Data.BulkUpdateContext" try { foreach($record in $countryItems) { $item = New-Item -Path $destinationPath -Name $record.Name -ItemType "{{Template to be used}}" $item.Editing.BeginEdit() $item["Title"] = $record["Title"] $item[...