44

You can do this by using the Powershell Extensions module. $item = get-item master:\content\Demo\Int\Home $device =Get-Device -Default $contentDataSource = get-item master:\content\Demo\Int\Home\about-us\employee-stories\adam-najmanowicz $ImageDataSource = get-item master:\content\Demo\Int\Data\Images\d56cf7e777a2496aa6489a7bffc03539 $rendering = get-item ...


23

Another option is to use the Sitecore search bulk update actions. Start a search at the root of your content tree (e.g. /sitecore/content/home). Click on the little magnifying glass Enter a search query to select all the content items you'd like to update (e.g Template: {your-template-guid-here} Click the little drop-down arrow then Search operations Then ...


21

August 2019 Update There is a report included with SPE allowing you to find images by a specific size. January 2018 Update - 6 months later So we've added a few more websites with media to our database. Updated results are below. I've also added a SQL Query example with looks promising but may give some people heartburn. Example: Use Sitecore Query to ...


19

A safer method would be to use the DbBrowser. You can find this by going to <yoursiteurl>/sitecore/admin/dbbrowser.aspx. You will get a screen where the content tree loads up on the left and you get a raw view of fields on the right: This screen does not run any of the validation elements from the main content editor. It just browses the database ...


16

I wrote a PowerShell cmldet for merging Final Renderings back into Shared Renderings. function Merge-Layout { [CmdletBinding()] param( [Parameter(Mandatory = $true,Position = 0,ValueFromPipeline = $true)] [item]$Item ) process { $layoutField = New-Object "Sitecore.Data.Fields.LayoutField" -ArgumentList ($Item.Fields[[...


15

Try this $database = "master" $homeItem = "$($database):\sitecore\content\home123" $homeExists = Test-Path -Path $homeItem


14

There is already one blog post on this topic on Internet Code snippet from the blog as below: Add-ItemLanguage -Path "master:\sitecore\content" -Language "en" -TargetLanguage "de-DE" -IfExist OverwriteLatest -IgnoredFields "" For recursive you can try below PowerShell script Get-ChildItem /sitecore/content/home -Recurse | Where-Object { $_."...


14

This is how you could use the using statement inside Powershell function Using-Object { [CmdletBinding()] param( [Parameter(Mandatory = $true)] [AllowEmptyString()] [AllowEmptyCollection()] [AllowNull()] [object] $InputObject, [Parameter(Mandatory = $true)] [scriptblock] $...


14

In SPE you should be able to do the following to get a list of all users with the admin role. This should get you users, with admin role who are not the default admin $users = Get-User -Filter* | Where-Object {$_.IsAdministrator -and $_.Profile.UserName -ne 'sitecore\admin'} Then you should pipe through the $users variable add a new role and user ...


14

I do know that I personally built 5.1 to address the compatibility issue with jobs. I encourage you to consider trying that to confirm it corrects the issue. https://github.com/SitecorePowerShell/Console/releases For some clarification. The official SPE builds on GitHub have embedded the VersionSpecific dll into the primary dll. When the installation ...


13

I wouldn't use Sitecore Powershell Extensions for this. SPE doesn't have anything for interacting with the clipboard and also doesn't execute custom JS from scripts (yet!). Additionally, there already exists a command within Sitecore for copying the path to the clipboard, so all you need to do is assign it to a new button in the context menu. John West has ...


11

You can use this to set it to empty. With this you don't need to wrap the change with BeginEdit and EndEdit $item."__Display Name" = "" You only need the quotes here as there is a space in the name, a field without a space can be accessed like so: $item.MyField If you actually want to reset the field value, rather than explicitly set it as empty, use: ...


11

Quick test confirms that the following allows you to set a rendering parameter on existing items. # Path to the Coveo rendering you need to update $rendering = Get-Item "master:\sitecore\layout\Sublayouts\Sample Sublayout" # Update this value for the path of all the templates whose std vals you wish to update $items = Get-ChildItem -recurse master:\...


11

SPE loses Sitecore context if /sitecore/content/home item is not present and falls back to Windows context. To force it to use the master database set the location at the top of your script: Set-Location master: You can also set the context from the ISE window from the ribbon: This was raised as an issue on Github and has been fixed in SPE 4.2 so that ...


11

I found some code from John West some time back and made that into a module on Github. You could take the below snippet I converted to PowerShell and make it a report. # Create a list of field names on the Standard Template. This will help us filter out extraneous fields. $standardTemplate = Get-Item -Path "master:" -ID "{1930BBEB-7805-471A-A3BE-...


11

If personalisation is enabled for an item, then there will be a parameter named rules, when we get the rendering using "Get-Rendering". The same can be done for a parent item and run the code for child items which has Rules in its renderings. I have made a code snippet that will get all the items that has personalization defined function GetPersonalization(...


11

There is a report included with SPE called Items with Template that can provide you with this information. This report scans a tree and checks for inheritance at any level. Slow because it has to look at every item. Incomplete because it only looks at the tree specified. I would recommend you use the Get-ItemReferrer command. This is based on the Link ...


11

You can use the below script to remove all empty p/P tags (having space or &nbsp;). This script uses the HtmlDecode method of System.Web.HttpUtility class to decode single or multiple occurrences of &nbsp; to an empty string and then Regex replaces p tags with or without spaces. $items = Get-ChildItem "master:/sitecore/content" -Recurse -Language *...


10

Based on your question I think you need something that will require a bit more finesse, so here's my attempt - It will only show renderings that have no datasource, but need them function Test-DataSourceRequired { [CmdletBinding()] param([Sitecore.Data.ID]$RenderingId) $rendering = Get-Item master: -ID $RenderingId # if data source ...


10

You can use Sitecore Contextual Ribbon to do the above task. You will not require to do any code implementation. You need to create the ribbon in Core database at the path /sitecore/content/Applications/Content Editor/Ribbons/Contextual Ribbons. Then, from the master database, navigates to the item template where you want the ribbon to appear and search ...


10

I recently discovered this issue on my local instance of SPE while working on 5.1. Corey Smith showed me how to resolve this issue as it recently came up with Unicorn. Apply the following patch for instances of Sitecore (9.1+) to fix the issue. <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/...


9

After currently executing "line of code" will finish its job then script execution will be immediately suspended once you click Abort. So you don't have to control execution by your own. What is currently running must finish its work (single instruction, let's say Write-host 'test', this cannot be interrupted anywhere between). This is more or less the ...


9

SPE is only required for environments that use the Sitecore interface. If you are going to use the Content Editor or Experience Editor then install the module. Essentially only the CM needs SPE.


9

You can use below powershell script (https://gist.github.com/marcduiker/950e0358bb4752ed5b047931a8c958c1) : # This is the ID of the workflow that will be set on the content items. $script:workflowID = "{A5BC37E7-ED96-4C1E-8590-A26E64DB55EA}" #Sample Workflow # This is the ID of the workflow state that will be set on the content items. $script:...


9

An alternative would be to run the Get-Item command and provide the necessary ErrorAction parameter to hide the output. # Variable $item will contain the object if found. if(($item = Get-Item -Path "master:\content\home1" -ErrorAction SilentlyContinue)) { $item } else { Write-Host "Does not exist." } Sometimes you may also see the parameter ...


9

The script we use to bundle up SPE can be found here: /sitecore/system/Modules/PowerShell/Script Library/Platform/Development/PowerShell Extensions Maintenance/Prepare Console Distribution. From the documentation here: Creates new Item source that can be added to a Sitecore package. Item provided to it is added as well as its subitems. New-ItemSource ...


8

Wrapping your code in a BulkUpdateContext block as mentioned in the Powershell GitBook will make the tasks more performant and also silence any events or tasks. Import-Function -Name New-UsingBlock New-UsingBlock (New-Object Sitecore.Data.BulkUpdateContext) { # insert cleanup code here... }


8

The SPE Gitbook provides some alternate examples using the $using:VARIABLE syntax. Example: The following will pass the $data object into the scriptblock for remote execution. Import-Module -Name SPE $session = New-ScriptSession -Username michael -Password b -ConnectionUri https://spe.dev.local $data = @{"name"="Michael"} Invoke-RemoteScript -Session $...


8

You can set context language using Syntax: #get language to be switched $lan = [Sitecore.Globalization.Language]::Parse("$switchLanguage") #Set Context language, use 'ispersistent' parameter based on your requirement.in my case it should be for a while i.e. creation of master content. [Sitecore.Context]::SetLanguage( $lan,$false) Below is one of the ...


8

This is related to the following bug in SPE 4.4. There are 2 courses of action you can take: Upgrade your Windows PowerShell to 5. (Windows Management Framework 5.x) Upgrade SPE to 4.5 Actually taking the approach #2 is preferable as we've fixed quite a few other issues there and Upgrading Windows PowerShell can have consequences on your whole environment ...


Only top voted, non community-wiki answers of a minimum length are eligible