Created
June 18, 2025 17:00
-
-
Save michaellwest/f4a0d0aae39c0ea3ccb855772ed2afbb to your computer and use it in GitHub Desktop.
Writes settings to the Sitecore registry using Sitecore PowerShell Extensions (SPE).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$previouslySelectedKey = "previously.selected.databases"; #you should change this to something that makes sense to you | |
$previouslySelectedString = [Sitecore.Web.UI.HtmlControls.Registry]::GetString($previouslySelectedKey); | |
$previouslySelected = $previouslySelectedString.Split(","); | |
$targets = [ordered]@{"Web"="web"; "Preview"="webpreview"}; | |
$props = @{ | |
Parameters = @( @{ Name="selectedTargets"; Title="Choose Targets"; Editor="checklist"; Options=$targets; Value=$previouslySelected; Tooltip = "Select one or more targets" } ) | |
Title = "Publish Item and Local Data" | |
Description = "Select the relevant publishing settings for the item." | |
Width = 500 | |
Height = 500 | |
ShowHints = $true | |
} | |
$result = Read-Variable @props | |
if (($result -eq 'cancel') -or (-not $selectedTargets)) { | |
Write-Host "No target was selected." -ForegroundColor Yellow | |
return | |
} | |
$previouslySelectedString = [string]::Join(",", $selectedTargets) | |
[Sitecore.Web.UI.HtmlControls.Registry]::SetString($previouslySelectedKey, $previouslySelectedString) #persist for use in the next instance of this dialog | |
Write-Host "target was selected." -ForegroundColor Green |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment