Sitecore PowerShell Extensions
  • Introduction
  • Disclaimer
  • Installation
    • Contributor Guide
  • Training
  • Community
  • Interfaces
    • Console
    • Scripting
    • Interface Configuration
    • Interactive Dialogs
    • Help
  • Working with Items
    • Item Languages
    • Item Renderings
    • Variables
    • Providers
  • Modules
    • Libraries and Scripts
    • Integration Points
      • Content Editor
      • Control Panel
      • Data Sources
      • Event Handlers
      • Functions
      • ISE Plugins
      • Page Editor
      • Pipelines
      • Reports
        • Authoring Reports
      • Tasks
        • Authoring Tasks
      • Toolbox
      • Web API
      • Workflows
    • Packaging
  • Remoting
  • Security
    • Users and Roles
  • Releases
  • Troubleshooting
  • Code Snippets
    • Item Links
    • Field Types
    • Manage Templates
  • Appendix
    • Common
      • Add-BaseTemplate
      • Add-ItemVersion
      • Close-Window
      • ConvertFrom-CliXml
      • ConvertFrom-ItemClone
      • ConvertTo-CliXml
      • Expand-Token
      • Get-Archive
      • Get-ArchiveItem
      • Get-Cache
      • Get-Database
      • Get-ItemClone
      • Get-ItemCloneNotification
      • Get-ItemField
      • Get-ItemReference
      • Get-ItemReferrer
      • Get-ItemTemplate
      • Get-ItemWorkflowEvent
      • Get-SitecoreJob
      • Get-SpeModule
      • Get-SpeModuleFeatureRoot
      • Get-TaskSchedule
      • Get-UserAgent
      • Import-Function
      • Invoke-JavaScript
      • Invoke-Script
      • Invoke-ShellCommand
      • Invoke-Workflow
      • New-ItemClone
      • New-ItemWorkflowEvent
      • New-UsingBlock
      • Out-Download
      • Publish-Item
      • Read-Variable
      • Receive-File
      • Receive-ItemCloneNotification
      • Remove-BaseTemplate
      • Remove-ArchiveItem
      • Remove-ItemVersion
      • Reset-ItemField
      • Restart-Application
      • Restore-ArchiveItem
      • Send-File
      • Send-SheerMessage
      • Set-HostProperty
      • Set-ItemTemplate
      • Show-Alert
      • Show-Application
      • Show-Confirm
      • Show-FieldEditor
      • Show-Input
      • Show-ListView
      • Show-ModalDialog
      • Show-Result
      • Show-YesNoCancel
      • Start-TaskSchedule
      • Test-BaseTemplate
      • Test-Rule
      • Update-ItemReferrer
      • Update-ListView
      • Write-Log
    • Indexing
      • Find-Item
      • Get-SearchIndex
      • Initialize-Item
      • Initialize-SearchIndex
      • Initialize-SearchIndexItem
      • Remove-SearchIndexItem
      • Resume-SearchIndex
      • Stop-SearchIndex
      • Suspend-SearchIndex
    • Packaging
      • Export-Item
      • Export-Package
      • Export-UpdatePackage
      • Get-Package
      • Get-Preset
      • Get-UpdatePackageDiff
      • Import-Item
      • Install-Package
      • Install-UpdatePackage
      • New-ExplicitFileSource
      • New-ExplicitItemSource
      • New-FileSource
      • New-ItemSource
      • New-SecuritySource
      • Import-Item
      • New-Package
    • Presentation
      • Add-PlaceholderSetting
      • Add-Rendering
      • Get-Layout
      • Get-LayoutDevice
      • Get-PlaceholderSetting
      • Get-Rendering
      • Get-RenderingParameter
      • Merge-Layout
      • New-PlaceholderSetting
      • New-Rendering
      • Remove-PlaceholderSetting
      • Remove-Rendering
      • Remove-RenderingParameter
      • Reset-Layout
      • Set-Layout
      • Set-Rendering
      • Set-RenderingParameter
      • Switch-Rendering
    • Provider
      • Get-Item
    • Security
      • Add-ItemAcl
      • Add-RoleMember
      • Clear-ItemAcl
      • Disable-User
      • Enable-User
      • Export-Role
      • Export-User
      • Get-Domain
      • Get-ItemAcl
      • Get-Role
      • Get-RoleMember
      • Get-User
      • Import-Role
      • Import-User
      • Lock-Item
      • Login-User
      • Logout-User
      • New-Domain
      • New-ItemAcl
      • New-Role
      • New-User
      • Protect-Item
      • Remove-Domain
      • Remove-Role
      • Remove-RoleMember
      • Remove-User
      • Set-ItemAcl
      • Set-User
      • Set-UserPassword
      • Test-Account
      • Test-ItemAcl
      • Unlock-Item
      • Unprotect-Item
      • Unlock-User
    • Session
      • Get-ScriptSession
      • Get-Session
      • Receive-ScriptSession
      • Remove-ScriptSession
      • Remove-Session
      • Start-ScriptSession
      • Stop-ScriptSession
      • Wait-ScriptSession
Powered by GitBook
On this page
  • Simple Dialogs
  • Alert
  • Confirmation
  • User Input
  • Advanced Dialogs
  • Variable Settings
  • Confirmation Choice
  • Upload
  • Download
  • Field Editor
  • File Browser
  • Data List
  • Results
Export as PDF
  1. Interfaces

Interactive Dialogs

PreviousInterface ConfigurationNextHelp

Last updated 2 years ago

We've provided a few commands to interact with the user through dialogs.

Simple Dialogs

Simple in the sense that the dialogs present the user with a short message and one or two buttons.

Alert

The Alert dialog is a way to notify the user of important information with an "OK" button.

Example: The following display a modal dialog.

Show-Alert -Title "SPE is great!"

No return value.

Confirmation

The Confirmation dialog is a way to verify with the user before proceeding.

Example: The following displays a modal dialog with an OK or Cancel confirmation.

Show-Confirm -Title "Click OK to acknowledge SPE is great!"
Button Name
Return Value

OK

yes

Cancel

no

User Input

Example: The following displays an input dialog for text.

Show-Input "Please provide 5 characters at most" -MaxLength 5
Button Name
Return Value

OK

< user input >

Cancel

$null

Example: The following displays an input dialog with a error validation message.

$inputProps = @{
    Prompt = "Enter a new name for the item:"
    Validation = [Sitecore.Configuration.Settings]::ItemNameValidation
    ErrorMessage = "'`$Input' is not a valid name."
    MaxLength = [Sitecore.Configuration.Settings]::MaxItemNameLength
}

Show-Input @inputProps

Advanced Dialogs

Variable Settings

The Read-Variable command provides a way to prompt the user for information and then generate variables with those values.

Example: The following displays a dialog with a dropdown.

Note: The name selectedOption will result in a variable that contains the selected option.

$options = @{
    "A"="a"
    "B"="b"
}

$props = @{
    Parameters = @(
        @{Name="selectedOption"; Title="Choose an option"; Options=$options; Tooltip="Choose one."}
    )
    Title = "Option selector"
    Description = "Choose the right option."
    Width = 300
    Height = 300
    ShowHints = $true
}

Read-Variable @props
Button Name
Return Value

OK

ok

Cancel

cancel

< variables >

< selection >

Supported Parameter Values

Key
Type
Description
Example

Name

string

Variable name

isSilent

Value

bool string int float datetime Item

Default value

$true

Title

string

Header or Label

"Proceed Silently

Tooltip (optional)

string

Short description or tooltip

"Check to run quietly

Tab (optional)

string

Tab title

"Simple"

Placeholder (optional)

string

Textbox placeholder

"Search text..."

Lines (optional)

int

Line count

3

Editor (optional)

string

Control type

"date time"

Domain (optional)

string

Domain name for security editor

"sitecore"

Options (optional)

string OrderedDictionary Hashtable

Data for checklist or dropdown

@{"Monday"=1;"Tuesday"=2}

Columns

int string

Number between 1 and 12 and string 'first' or 'last'

6 first

Editor Types

  • bool

  • check

  • date

  • date time

  • droplist

  • droptree

  • email

  • groupeddroplink

  • groupeddroplist

  • info

  • item

  • link

  • marquee

  • multilist

  • multilist search

  • multiple user

  • multiple user role

  • multiple role

  • multitext

  • number

  • pass

  • radio

  • rule

  • rule action

  • tree

  • treelist

  • tristate

  • time

Confirmation Choice

The Confirmation Choice dialog allows for multiple combinations like that seen with a "Yes, Yes to all, No, No to all" scenario.

Example: The following displays a modal dialog with choices.

Show-ModalDialog -Control "ConfirmChoice" -Parameters @{btn_0="Yes - returns btn_0"; btn_1="No - returns btn_1"; btn_2="returns btn_2"; te="Have you downloaded SPE?"; cp="Important Questions"} -Height 120 -Width 650

Note: The hashtable keys should be incremented like btn_0, btn_1, and so on. The return value is the key name.

Button Name
Return Value

< first button >

btn_0

< second button >

btn_1

< third button >

btn_2

Upload

The Upload dialog provides a way to upload files from a local filesystem to the media library or server filesystem.

Example: The following displays an advanced upload dialog.

Receive-File (Get-Item "master:\media library\Files") -AdvancedDialog

No return value.

Download

The Download dialog provides a way to download files from the server to a local filesystem.

Example: The following displays a download dialog.

Get-Item -Path "master:\media library\Files\readme" | Send-File

Field Editor

The Field Editor dialog offers a convenient way to present the user with fields to edit.

Example: The following displays a field editor dialog.

Get-Item "master:\content\home" | Show-FieldEditor -Name "*" -PreserveSections
Button Name
Return Value

OK

ok

Cancel

cancel

File Browser

The File Browser is an obvious choice when you need to upload, download, or delete files.

Example: The following displays a file browser dialog for installation packages.

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"
Button Name
Return Value

OK

< selected file >

Cancel

undetermined

Example: The following displays a simple file browser dialog.

Show-ModalDialog -HandleParameters @{
    "h"="FileBrowser";
} -Control "FileBrowser" -Width 500
Button Name
Return Value

OK

< selected file >

Cancel

undetermined

Example: The following displays a Sheer UI control without any additional parameters.

Show-ModalDialog -Control "SetIcon"

Data List

The "Data List" is essentially a report viewer which supports custom actions, exporting, and filtering.

Example: The following displays a list view dialog with the child items under the Sitecore tree.

Get-Item -Path master:\* | Show-ListView -Property Name, DisplayName, ProviderPath, TemplateName, Language

Results

The Results dialog resembles the Console but does not provide a prompt to the user. This is useful for when logging messages.

Example: The following displays a dialog with the all the information written to the ScriptSession output buffer.

for($i = 0; $i -lt 10; $i++) {
    Write-Verbose "Index = $($i)" -Verbose
}

Show-Result -Text
Show Alert
Show Confirm
Show Input
Show Input
Read Variable
Show Confirm Choice
Receive File
Download
Show Field Editor
Show File Browser
Show File Browser
Show List View
Show Result Text