Skip to content

Instantly share code, notes, and snippets.

@AdamNaj
Last active December 5, 2016 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdamNaj/c3b7ee512eed0faa1b96 to your computer and use it in GitHub Desktop.
Save AdamNaj/c3b7ee512eed0faa1b96 to your computer and use it in GitHub Desktop.
Dialog Test Script
#Host Color test
$Host.UI.RawUI.BackgroundColor = ($bckgrnd = 'White')
$Host.UI.RawUI.ForegroundColor = 'Black'
$Host.PrivateData.ErrorForegroundColor = 'Red'
$Host.PrivateData.ErrorBackgroundColor = $bckgrnd
$Host.PrivateData.WarningForegroundColor = 'Magenta'
$Host.PrivateData.WarningBackgroundColor = $bckgrnd
$Host.PrivateData.DebugForegroundColor = 'Blue'
$Host.PrivateData.DebugBackgroundColor = $bckgrnd
$Host.PrivateData.VerboseForegroundColor = 'Green'
$Host.PrivateData.VerboseBackgroundColor = $bckgrnd
$Host.PrivateData.ProgressForegroundColor = 'DarkCyan'
$Host.PrivateData.ProgressBackgroundColor = $bckgrnd
Write-Host "Write-Host color test"
Write-Debug "Write-Debug color test" -Debug
Write-Verbose "Write-Verbose color test" -Verbose
Show-Result -Text
#Show field editor for Home item
Get-Item master:\content\home | Show-FieldEditor -Name Title, Text
#Download file dialog - first log from the logs folder
Get-ChildItem $SitecoreLogFolder | select -first 1 | Send-File
#Item deletion confirm dialog
New-Item -Path master:\content\home -ItemType "Common/Folder" -Name Test | Remove-Item -Confirm
#Debug message confirm dialog
Write-Debug "Test" -Debug
#Read Variable dialog
Invoke-Script "master:\system\Modules\PowerShell\Script Library\Getting Started\User Interaction\Read-Variable - Sample"
#Mandatory fields
$item = $null;
Read-Variable -Parameters `
@{ Name = "item"; Root="/sitecore/content/"; Mandatory=$true; editor="item allownone"},
@{ Name = "text"; Value=""; Mandatory=$true},
@{ Name = "checks"; Options="First|a|Second|b"; Editor="checklist"; Mandatory=$true} `
-Width 450 -Height 500
#Write-Progress
Invoke-Script "master:\system\Modules\PowerShell\Script Library\Getting Started\Script Testing\Long Running Script with Progress Demo"
#Write-Progress
Receive-File -Title "Test File Upload" -Description "Test Description" -Path $SitecorePackageFolder
#Write-Progress
Receive-File -ParentItem (gi "master:\media library") -AdvancedDialog
#GetStringResponse control - not really used anywhere
Show-ModalDialog -Control "GetStringResponse" -Height 200
# Uses Show-ModalDialog to execute the ConfirmChoice XML control
# the buttons must be named btn_0, btn_1...
Show-ModalDialog -Control "ConfirmChoice" -Parameters @{btn_0="Yes (returns btn_0)"; btn_1="No (returns btn_1)"; btn_2="return btn_2"; te="Message Text"; cp="My Caption"} -Height 120 -Width 500
#Show List View - Selected Fields - Rich renderers
Import-Function "Render-ReportField"
$script = Get-Item master:\ -ID "{EE75FFCF-7B3A-46CD-86AB-6536AD8675AA}"
$index = "sitecore_master_index"
Get-ChildItem master:\ | Show-ListView -Property `
ProviderPath, @{Label="Display Name"; Expression={ $_.DisplayName }},
HasChildren, TemplateName,
@{Label="Random Percent"; Expression={ Render-PercentValue (Get-Random -minimum 1 -maximum 100) -Width 100 }},
@{Label="Thumbnail"; Expression={ Render-ItemField $_ __thumbnail }},
@{Label="Index Fields"; Expression={ Render-ScriptInvoker $script @{index=$index; itemId="$($_.Uri)"} "Show Index Info" } } `
#Show List View - Default Fields - Modal
Get-ChildItem master:\ | Show-ListView -Modal
#Item Browser
Show-ModalDialog -Control "PowerShellScriptBrowser"
#Interactive session spawning
$scriptPath = "master:\system\Modules\PowerShell\Script Library\Getting Started\Script Testing\Long Running Script with Progress Demo"
$scriptItem = Get-Item $scriptPath
$script = [scriptblock]::Create($scriptItem.Script)
Start-ScriptSession -Path $scriptPath -Interactive -AutoDispose
Start-ScriptSession -Item $scriptItem -Interactive -AutoDispose
Start-ScriptSession -ScriptBlock $script -Interactive -AutoDispose
#Field Editor
Get-Item "master:\content\Home" | Show-FieldEditor
# Executes Publishing Viewer by launching a Sitecore shell command
get-item "master:\content\Home" | Execute-ShellCommand -Name "item:publishingviewer"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment