Skip to content

Instantly share code, notes, and snippets.

@michaellwest
Created June 18, 2025 17:00
Show Gist options
  • Save michaellwest/f4a0d0aae39c0ea3ccb855772ed2afbb to your computer and use it in GitHub Desktop.
Save michaellwest/f4a0d0aae39c0ea3ccb855772ed2afbb to your computer and use it in GitHub Desktop.
Writes settings to the Sitecore registry using Sitecore PowerShell Extensions (SPE).
$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