Only this pageAll pages
Powered by GitBook
Couldn't generate the PDF for 200 pages, generation stopped at 100.
Extend with 50 more pages.
1 of 100

Sitecore PowerShell Extensions

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Introduction

About the Module

The module provides a command line (CLI) and a scripting environment (ISE) for automating tasks. SPE works with the Sitecore process, capable of making native calls to the Sitecore API and manipulating files. Running commands and writing scripts follow the standard and well-known Windows PowerShell syntax. Windows PowerShell is a common tool used in IT for desktop and server management, so we decided to stick with that as a framework to build upon.

Development Team

Bundled Tools

The following are some helpful modules distributed with SPE.

  • Core

    • Platform

      • PowerShell Background Session Manager

      • Recreate site from sitemap

  • Extensions

  • Maintenance

    • Index On Demand

    • Media Library Maintenance

    • System Maintenance

    • Task Management

  • Reporting

  • Samples

    • Automatically show quick info section

    • Enforce user password expiration

    • Example Event Handlers

    • Getting Started - includes the Kitchen Sink Demo for Read-Variable.

    • License Expiration

    • Random desktop background

    • Training Modules

    • Unlock user items on logout

  • Tools

    • Authoring Instrumentation

    • Copy Renderings

    • Data Management

      • Bulk Data Generator - useful for items and users

      • Bulk Item Restorer - restore items from recycle bin

      • Bulk Template Changer - can't think of a better description than this

      • Data Importer - create or update items from a Csv

      • Find and Replace - use Content Search to change text

    • Elevated Unlock - provides options to unlock items using delegated administration

    • Package Generator - a simple method to package up items

    • Publishing Status Gutter

    • Security Management

      • Logged in Session Manager

      • Transfer item security

  • Training

Endorsements

Help and Support

Disclaimer: With great power comes great responsibility – this tool can do a lot of good but also bring harm to a lot of content in a very short time – backup your system before running a script that modifies your content and never run any untested scripts in a production environment! We will not be held responsible for any use of it. Test your scripts on your development server first! Test on an exact copy of production before running scripts on production content.

The (SPE) module is a Sitecore development accelerator that can drastically increase your productivity and curtail the amount of time it takes to deliver a Sitecore solution.

The book provides documentation about how to use the module based on the latest released version. While some of the screenshots and materials may be slightly out-of-date, you will inevitably find details referring to something that doesn't exist on your installed version. Feel free to submit a pull request for corrections .

Support for Sitecore 7 has discontinued with SPE 5.0. Check the for version compatibility.

|

|

X-UnitTests - examples at how to use to test your scripts

- reports based on the Sitecore Rules Engine.

- similar to the Luke tool

- variety of reports to help audit the Sitecore solution.

There is nothing you can not do with PowerShell Console, because you're inside the Sitecore application. You can call the Sitecore API. - - Sitecore Symposium 2012

Recommended by to use as a tool for .

Get a job done with a one liner! Just provisioned a new language for the whole content tree with a one-liner. Whaaaat? Have to include it as a default install for all sandboxes now. - 's comment on Marketplace

Thank you for the GitBook. Invaluable Reference. - 's

The Sitecore powershell tools are absurdly good and helpful. I know they make a lot of people nervous, but they are incredibly well managed. Everybody should learn to sling some shell in Sitecore, you'll never look back. -

I literally couldn't work without SPE - I can't remember the last implementation I did that didn't have it installed lol @michaellwest & @adamnaj better not ever retire it -

See the section for some common fixes.

Questions, comments, and feature requests should be submitted on . You may also check out the for more interactive support. Not on Slack yet? Contact us on Twitter and we'll send you an invite.

Sitecore PowerShell Extensions
here
appendix
Adam Najmanowicz
@adamnaj
Michael West
@michaelwest101
Pester
Authorable Reports
Index Viewer
Scheduled Task Manager
Content Reports
Alistair Deneys
John West
maximizing Sitecore developer productivity
Alex Shyba
Nick Wesselman
tweet
Christopher Campbell
tweet
😄
Richard Seal
Troubleshooting
GitHub
SPE Slack channel

Disclaimer

Since every environment is different, all code should not be run in a production environment without your team or organization thoroughly testing first. We recommend the use of a test lab environment often referred to as a development/staging instance of Sitecore.

The disclaimer is provided because someone somewhere will inevitably not follow this recommendation and if they do hose their Sitecore environment, they have no one to blame but themselves.

All data and information provided in this book are for informational purposes only. Adam Najmanowicz, Michael West, and the SPE Team make no representations as to accuracy, completeness, currentness, suitability, or validity of any information in this book and will not be liable for any errors, omissions, or delays in this information or any losses, injuries, or damages arising from its display or use. All information found in this book is provided "as is" with no express or implied warranties.

Installation

Review prerequisites and details on how to get setup with SPE.

Prerequisites

  • Windows Management Framework 5.1 (PowerShell) is generally available for most Windows environments.

Docker

Working with Docker is going to be the preferred method of installation.

You can find two flavors of the images:

    • Ex: docker pull sitecorepowershell/sitecore-powershell-extensions:6.4-1809

  • Sitecore Built

    • Ex: docker pull scr.sitecore.com/sxp/modules/sitecore-spe-assets:6.4-1809

With this approach, you essentially add a new layer during your image build to include the files from the asset image. Here are some samples of what you can add to your existing setup. Check out Sitecore's samples for additional guidance.

docker-compose.yml

services:
  mssql-init:
    image: ${REGISTRY}${COMPOSE_PROJECT_NAME}-xm1-mssql-init:${VERSION:-latest}
    build:
      context: ./docker/build/mssql-init
      args:
        BASE_IMAGE: ${SITECORE_DOCKER_REGISTRY}sitecore-xm1-mssql-init:${SITECORE_VERSION}
        SPE_IMAGE: ${SITECORE_MODULE_REGISTRY}sitecore-spe-assets:${SPE_VERSION}
  cm:
    image: ${REGISTRY}${COMPOSE_PROJECT_NAME}-xm1-cm:${VERSION:-latest}
    build:
      context: ./docker/build/cm
      args:
        BASE_IMAGE: ${SITECORE_DOCKER_REGISTRY}sitecore-xm1-cm:${SITECORE_VERSION}
        SPE_IMAGE: ${SITECORE_MODULE_REGISTRY}sitecore-spe-assets:${SPE_VERSION}

Dockerfile (mssql-init)

# escape=`

ARG BASE_IMAGE
ARG SPE_IMAGE

FROM ${SPE_IMAGE} as spe
FROM ${BASE_IMAGE}

COPY --from=spe C:\module\db C:\resources\spe

Dockerfile (cm)

# escape=`

ARG BASE_IMAGE
ARG SPE_IMAGE

FROM ${SPE_IMAGE} as spe
FROM ${BASE_IMAGE}

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

WORKDIR /inetpub/wwwroot

COPY --from=spe \module\cm\content .\

Installation Wizard

The SPE module installs like any other for Sitecore. This approach is appropriate for installations not within a containerized environment.

  • For Sitecore 10.1 and newer along with Identity Server you should enable the provided configuration Spe.IdentityServer.config.

  • For Sitecore 10.1 and newer you can leverage the IAR packages. There is still the need for dacpac deployments because SPE includes a security user and role.

Upgrade

We've tried to make upgrading SPE as seamless as possible. The following should provide you with some basic information on what to expect when upgrading.

From 6.x

You should be able to install directly over the previous installation of 6.0+.

  • For Sitecore 10.1 and newer along with Identity Server you should enable the provided configuration Spe.IdentityServer.config.

  • For Sitecore 10.1 and newer you can leverage the IAR packages. There is still the need for dacpac deployments because SPE includes a security user and role.

From 5.x and older

These versions used a different name for the assemblies and configs. You may find it easier to delete all files originally distributed with SPE before installing a newer version. Here are a few steps to consider:

  • Delete all files in the bin and App_Config/Include directories prefixed with Cognifide.

  • Delete /sitecore modules/Shell/PowerShell

  • Delete /sitecore modules/PowerShell

Reference the original SPE package (if available) to identify if any other files were included.

Sitecore items in the content tree will potentially shuffle around into their new location. Be sure to backup your custom scripts first.

Troubleshooting

Training

Beginner's guide to working with PowerShell and SPE.

The world renowned Sitecore PowerShell Extensions module has so much to offer, but sometimes those new to the module may find it difficult to know where to start. The following book should provide you with enough information to use and be productive with SPE.

Don't worry, you will be able to use it without having to write any code.

Videos and Blogs

Language Basics

PowerShell is built on the Microsoft .Net technology; you will find that most APIs in your libraries can be accessed from within the PowerShell runtime. In this section we will see similarities between the C# and PowerShell syntax.

C# to PowerShell

Use the table below to aid in translating from C# to PowerShell. Some of the examples below are not "exact" translations, but should give you a good idea on what it would look like. For example, creating a new dynamic list in C# is often written as a fixed dimensional array recreated with every new addition.

Note: Variables in PowerShell are denoted by the $ character followed by the name. You will see this through the examples below.

// Perform simple math in C#
var total = 1 + 1;
total += 2;
# Perform simple math in PowerShell
$total = 1 + 1
$total += 2

Working with Dynamic and Fixed dimensional arrays.

/*
  Create a new dynamic list of strings in C#
*/
var names = new List<string>();
names.Add("Michael");
names.Add("Adam");
<#
  Create a new fixed list of strings in PowerShell
#>
[string[]]$names = @()
$names += "Michael"
$names += "Adam"

Working with hashtables.

// Create a hashtable of data in C#
var table = new Hashtable();
table["Name"] = "Michael";
table["Age"] = 33;
# Create a new hashtable of data in PowerShell
$table = @{}
$table["Name"] = "Michael"
$table["Age"] = 33

Working with dictionaries.

// Ordered Dictionary in C#
var od = new OrderedDictionary();
od.Add("z","Last Letter");
od.Add("a","First Letter");
# Ordered Dictionary in PowerShell
$od = [ordered]@{}
$od.Add("z","Last Letter")
$od.Add("a","First Letter")
// Check if the string is null or empty using a static method in C#
if(string.IsNullOrEmpty(name)) { 
  ...
}
else {
  ...
}
# Check if the string is null or empty using a static method in PowerShell
if([string]::IsNullOrEmpty($name)) {
  ...
} else {
  ...
}
// Compare values in C#
name == "Michael"
total <= 3 names.Count() > 2 && name[0] != "Adam"
# Compare values in PowerShell
$name -eq "Michael"

# case-insensitive
$total -le 3 $names.Count -gt 2 –and $name[0] -ne "Adam"
// Negate value in C#
var isTrue = !false;
# Negate value in PowerShell
$isTrue = !$false
$isTrue = -not $false
// String interpolation in C#
var message = $"Hello, {name}";
# String interpolation in PowerShell
$message = "Hello, $($name)"

Escape double quotes in string. Alternatively you can use a single quote.

// Escape characters in C#
string message = "They said to me, \"SPE is the greatest!\".";
message = 'I said, "Thanks!"';
message = "We celebrated together, 'Go SPE!'";
# Escape characters in PowerShell
$message = "They said to me, `"SPE is the greatest!`"."
$message = 'I said, "Thanks!".'
$message = "We celebrated together, 'Go SPE!'."
// Access static property in C#
var today = DateTime.Today;
# Access static property in PowerShell
$today = [datetime]::Today

As you can see in the table above, the language syntax is not all that different between C# and PowerShell. Within a few minutes you might even be able to translate code from your library classes into SPE scripts.

Performance Considerations

You may find yourself trying to optimize your scripts. A few things that might help include the following.

Example: The following demonstrates the use of an ArrayList. Performs much better than purely using @().

# Use ArrayList to append items rather than creating new fixed dimensional arrays
$names = [System.Collections.ArrayList]@()
$names.Add("Michael") > $null
$names.Add("Adam") > $null

Example: The following demonstrates the use of List<string>. This is ideal when statically typed arrays are required.

# Optionally create static static typed arrays
$names = [System.Collections.Generic.List[string]]@()
$names.Add("Michael") > $null
$names.Add("Adam") > $null

Example: The following demonstrates the use of HashSet. Use when a distinct list of items is needed. Performs like a Dictionary but without the requirement for a key.

# HashSet when only values are needed
$nameLookup = New-Object System.Collections.Generic.HashSet[string]
$nameLookup.Add("Michael") > $null

Example: The following demonstrates the use of HashSet where the casing of the items are ignored.

# Case insensitive lookup
$nameLookup = New-Object System.Collections.Generic.HashSet[string]([StringComparer]::OrdinalIgnoreCase)
$nameLookup.Add("Michael") > $null

if($nameLookup.Contains("michael")) {
  Write-Host "Found it!" -ForegroundColor Green
} else {
  Write-Host "No esta aqui :-(" -ForegroundColor White -BackgroundColor Red
}

Example: The following demonstrates how to replace the use of Compare-Object with HashSet. This is useful and important when the collection size is large and you are working with simple data like strings. Compare-Object does offer a way to compare specific properties.

# Instead of using Compare-Object to compare two datasets, such as for strings or integeters, consider using HashSet instead.
# Populate collection
$referenceIds = [System.Collections.Generic.List[string]]@()
# Populate collection
$differenceIds = [System.Collections.Generic.List[string]]@()

<#
$leftOnlyObjects = Compare-Object -ReferenceObject $referenceIds -DifferenceObject $differenceIds | 
            Where-Object { $_.SideIndicator -eq "<=" } | Select-Object -ExpandProperty InputObject
#>
$referenceHash = New-Object 'System.Collections.Generic.HashSet[String]'
$referenceHash.UnionWith($referenceIds)
$differenceHash = New-Object 'System.Collections.Generic.HashSet[String]'
$differenceHash.UnionWith($differenceIds)
$leftOnlyHash = New-Object 'System.Collections.Generic.HashSet[String]'($referenceHash)
$leftOnlyHash.ExceptWith($differenceHash)
$leftOnlyObjects = $leftOnlyHash
# Queue when ... a queue is needed
$queue = New-Object System.Collections.Queue
$queue.Enqueue("{GUID}")
$queue.Dequeue()

Example: The following measures code execution time using Measure-Command.

Measure-Command -Expression {
    Get-Item -Path "master:" > $null
} | Select-Object -ExpandProperty TotalMilliseconds

Example: The following measures code execution time using a Stopwatch.

$watch = [System.Diagnostics.Stopwatch]::StartNew()
Get-Item -Path "master:" > $null
$watch.Stop()
$watch.ElapsedMilliseconds

Example: The following terminates the output.

# Slow but functional
$builder = New-Object System.Text.StringBuilder
$builder.Append("Hello World!") | Out-Null
$builder.ToString()

# Much faster
$builder = New-Object System.Text.StringBuilder
$builder.Append("Hello World!") > $null
$builder.ToString()

Checklist of performance tuning ideas:

  • Use dynamic arrays to avoid the use of +=

  • Suppress output with > $null instead of Out-Null

  • Use hashtables as lookup tables for data

PowerShell Commands

Learning PowerShell begins with running your first command. In this section we learn about the basic command syntax, and some common ones you should learn.

Syntax

Example: The following provides an example syntax for a fake command.

Get-Something [[-SomeParameter] <sometype[]>] [-AnotherParameter <anothertype>] [-SomeSwitch]

PowerShell commands follow a Verb-Noun syntax. Notice that all properly named commands start with a verb such as Get, Set, or Remove and end with a noun such as Item, User, or Role.

The noun in the command should be singular even if the command returns more than one object.

The parameters follow the command and usually require arguments. In our example above we have a parameter called SomeParameter followed by an argument of type SomeType. The final parameter SomeSwitch is called a switch. The switch is like a flag that enables or disables behavior for the command.

The brackets surrounding the parameter and the brackets immediately following a type have different meanings. The former has to do with optional usage whereas the latter indicates the data can be an array of objects.

Example: The following provides possible permutations for the fake command.

<#
    All of the parameters in the command are surrounded by square brackets 
    indicating they are optional.
#>
Get-Something
<# 
    SomeParameter has double brackets around the parameter name and argument 
    indicating the name is optional and when an argument is passed the name 
    can be skipped.
#>
Get-Something "data"
<#
    AnotherParameter has single brackets indicating that the parameter is 
    optional. If the argument is used so must the name. The same reasoning 
    can be applied to the switch.
#>
Get-Something "data","data2" -AnotherParameter 100 –SomeSwitch
# Splat parameters to command
$props = @{
    "SomeParameter" = @("data","data2")
    "AnotherParameter" = 100
    "SomeSwitch" = $true
}
Get-Something @props

Allow scripts to be written with the full command and parameter names

  • Avoid relying on positional or optional parameters.

  • Avoid abbreviating parameter names.

  • Avoid using command aliases (e.g. dir, cd).

Some of the most useful commands to learn can be seen in the table below. These come with vanilla PowerShell.

Command
Description

Get-Item

Returns an object at the specified path.

Get-ChildItem

Returns children at the specified path. Supports recursion.

Get-Help

Returns the help documentation for the specified command or document.

Get-Command

Returns a list of commands.

ForEach-Object

Enumerates over the objects passed through the pipeline.

Where-Object

Enumerates over the objects passed through the pipeline and filters objects.

Select-Object

Returns objects from the pipeline with the specified properties and filters objects.

Sort-Object

Sorts the pipeline objects with the specified criteria; usually a property name.

Get-Member

Returns the methods and properties for the specified object.

PowerShell was designed so that after learning a few concepts you can get up and running. Once you get past the basics you should be able to understand most scripts included with SPE.

Pipelines

PowerShell supports chaining of commands through a feature called "Pipelines" using the pipe "|". Similar to Sitecore in that you can short circuit the processing of objects using Where-Object. Let’s have a look at a few examples.

The characters $_ and $PSItem represent the current object getting processed in the pipeline.

Example: The following queries a Sitecore item and removes it.

# The remove command accepts pipeline input.
Get-Item -Path "master:\content\home\sample item" | Remove-Item

# If multiple items are passed through the pipeline each are removed individually.
$items | Remove-Item

PowerShell also comes with a set of useful commands for filtering and sorting. Let’s see those in action.

Example: The following queries a tree of Sitecore items and returns only those that meet the criteria. The item properties are reduced and then sorted.

# Use variables for parameters such as paths to make scripts easier to read.
$path = "master:\content\home\"

Get-ChildItem -Path $path -Recurse | 
    Where-Object { $_.Name -like "*Sitecore*" } | 
    Select-Object -Property ID,Name,ItemPath
    Sort-Object -Property Name

A best practice in PowerShell is to reduce the number of objects passed through the pipeline as far left as possible. While the example would work if the Sort-Object command came before Where-Object, we will see a performance improvement because the sorting has fewer objects to evaluate. Some commands such as Get-ChildItem support additional options for filtering which further improve performance.

Example: The following demonstrates how commands can be written clearly with little confusion on the intent, then how aliases and abbreviations can get in the way. Always think about the developer that comes after you to maintain the code.

# Longhand - recommended
Get-Command -Name ForEach-Object –Type cmdlet | Select-Object -ExpandProperty ParameterSets

# Shorthand - not recommend
gcm -na foreach-object -ty cmdlet | select -exp parametersets

Windows PowerShell is bundled with a ton of documentation that could not possibly be included with this book; we can however show you how to access it.

Example: The following examples demonstrate ways to get help…with PowerShell.

# Displays all of the about help documents.
help about_*

# Displays help documentation on the topic of Splatting.
help about_Splatting

# Displays help documentation on the specified command.
help Get-Member

PowerShell does not include the complete help documentation by default on Windows. Run the command Update-Help from an elevated prompt to update the help files to the latest available version. See help update-help for more information on the command syntax and details of its use. All of the SPE help documentation is available regardless of running Update-Help.

Providers

The provider architecture in PowerShell enables a developer to make a command like Get-Item interact with the filesystem files and folders, and then interact with the Sitecore CMS items.

The SPE module implements a new provider that bridges the Windows PowerShell platform with the Sitecore API. The following table demonstrates the use of Get-Item for a variety of providers.

Name
Drives
Example

Alias

Alias

Get-Item -Path alias:\dir

CmsItemProvider

core, master, web

Get-Item -Path master:\

Environment

Env

Get-Item -Path env:\HOMEPATH

FileSystem

C, D, F, H

Get-Item -Path c:\Windows

Function

Function

Get-Item -Path function:\prompt

Registry

HKLM, HKCU

Get-Item -Path hklm:\SOFTWARE

Variable

Variable

Get-Item -Path variable:\PSVersionTable

The default provider used by the PowerShell Console and ISE is the CmsItemProvider with the drive set to the master database.

Example: The following demonstrates switching between providers using the function cd, an alias for Set-Location, while in the Console.

PS master:\> cd c:\
PS C:\> cd hklm:
PS HKLM:\> cd env:
PS Env:\>

You may have noticed that the C drive is the only path in which a backslash was used before changing drives. Leaving off the backslash will result in the path changing to C:\windows\system32\inetsrv. This similar behavior can be experienced while in the Windows PowerShell Console, where the path is changed to C:\Windows\System32.

Interfaces

SPE includes several built-in interfaces for managing and executing scripts, as well as provides tools for modifying content.

Here we'll discuss the Console, ISE, and other dialogs made available through SPE.

Take a quick look at the to see which version of SPE you should be installing that is compatible with your Sitecore environment. Generally SPE has pretty good backwards compatibility but may require a new version to support the latest Sitecore CMS release.

PowerShell set to RemoteSigned (probably optional)

The release of SPE 6.0 introduced name changes to some files which are now reflected throughout the documentation. Review to see the full scope of what changed. Any place where the name Cognifide or Cognifide.PowerShell was used is now replaced with Spe.

the module from the GitHub releases page and install through the Installation Wizard.

An additional patch is required for 10.1 to include the location /sitecore modules/items/. See .

An additional patch is required for 10.1 to include the location /sitecore modules/items/. See .

Using packages with the Items as Resources (IAR) files will require additional steps to remove database records that correlate with the contents of the *.dat files. Refer to the Sitecore documentation when upgrading for the process to cleanup the databases. may be helpful if you wish to take a more precise approach.

See the troubleshooting section

We have a video series available to help walk you through the module .

We also maintain a comprehensive list of links to to help you on your journey to SPE awesomeness. Happy coding!

Example: The following demonstrates the use of Queue. A Sitecore Stack Exchange answer to may be helpful.

The verbs are considered “approved” if they align with those that Microsoft recommends. See the following URL for a list of approved verbs and a brief explanation on why they were chosen. They are intended to be pretty generic so they apply for multiple contexts like the filesystem, registry, and even Sitecore!

appendix
Execution Policy
issue #1109
Community Built
Download
Gist here
Gist here
This post
here
here
blogs and videos
find items based on a template
https://msdn.microsoft.com/en-us/library/ms714428(v=vs.85).aspx

Contributor Guide

Support for Sitecore 7 has discontinued with SPE 5.0.

The following guide should provide you with enough information to setup a development environment configured to contribute to SPE. We'll begin with a single installation of Sitecore 8+.

The solution requires Visual Studio 2015 or later.

This guide assumes a source root location of "C:\Source" and a site root location of "C:\inetput\wwwroot". These are not prerequisites of the project, and you can use whatever folder locations suit you.

Single Instance for Sitecore 8 & 9

  1. Install Sitecore 8+ to a folder of your choice, for example C:\inetpub\wwwroot\SitecoreSPE_8

  2. Clone the repo to your local development environment

    cd "C:\Source\Console"  // Your local source folder, with a new folder for the solution
    git init
    git remote add origin https://github.com/SitecorePowerShell/Console.git
    git fetch origin
    git checkout -b master --track origin/master
  3. Copy C:\Source\Console\deploy.user.json.sample to C:\Source\Console\deploy.user.json. This will be a file just for your local environment and will be ignored by git.

  4. Edit the sites definition in deploy.user.json to target your Sitecore web root folder, making sure you use double-slashes for paths like in the existing file. For this site, make sure the version property is 8. Remove any other sites in the file that do not apply.

    The deploy.user.json file supports deploying SPE to multiple Sitecore installations. For now, we are just deploying to a single instance, but later on in the tutorial we will cover multiple instances.

  5. Copy C:\Source\Console\UserConfiguration\App_Config\Include\z.Spe.Development.User.config.sample to a file of the same name, without the .sample suffix. This file can be edited to add any SPE-specific configuration that you want in your sites, but don't wish to commit back into the repo.

    You may notice there is a %%sourceFolder%% value in this configuration file. This is a special string that gets replaced as part of the SPE deployment with your source folder location. You don't need to update this manually.

  6. Open the solution in Visual Studio.

  7. Compile the solution. Whenever you compile the solution, SPE will be automatically deployed to the site web root paths you have set in deploy.user.json

  8. Login to Sitecore

  9. Navigate to /Unicorn.aspx. Use Unicorn to sync all projects into Sitecore.

  10. SPE is now installed in Sitecore and you're ready for developing!

Any changes you make going foward just require a build of the solution. Remember that when pulling down updates to the source, you should execute a Unicorn sync to ensure your items are up to date.

Multiple Instances

The SPE deployment process supports multiple sites and multiple versions of Sitecore. The following steps carry on from above to add further support for another Sitecore site, such as 8.x or 9.x.

  1. Complete the steps for a Single Instance.

  2. Install Sitecore 8.x/9.x to a folder of your choice, for example C:\inetpub\wwwroot\SitecoreSPE_91

  3. Edit the sites definition in deploy.user.json to add your new Sitecore web root folder. Set the version property to 9.0, 9.1 or 9.2 depending on the major/minor version.

  4. Follow steps 7 onward from the Single Instance guide above to deploy to your Sitecore 8.x/9.x installation and sync the SPE items into Sitecore.

SPE can be deployed to as many Sitecore sites as you like. Each time you first deploy to a new installation, make sure you use Unicorn to sync the latest state of items into Sitecore.

Optional: PowerShell Remoting support

To add the SPE PowerShell Remoting Module scripts into your machine's PowerShell Module path, execute the .\Setup_Module.ps1 script from the source folder. This will add the \Modules folder from source into your PSModulePath environment variable. Once this is done, you can use Import-Module SPE on your development machine to run the remoting scripts.

Optional: Junction Support

As part of the SPE deployment process, all of the relevant binary, configuration and sitecore module files are copied over from the projects within the solution. This means that any changes to static files such as JS / CSS files require a full build for these to be deployed to the site. As the build triggers an application pool recycle of your site, this can be a little slow for quick changes.

To enable a junction deployment for a site, add junction property to the site definition and set it to true:

{ 
    "sites": [
        {
            "path": "C:\\inetput\\wwwroot\\SitecoreSPE_8\\Website",
            "version": 8,
            "junction": true
        }
    ]
}

Note that with junction deployments, a solution build is still required if you want to deploy any code or .config changes.

It is not currently supported for a junction deployment site to be changed back into a non-junction deployment site. If you wish to do this, you should manually delete the following folders from your Sitecore installation before updating the junction property back to false: sitecore modules\PowerShell and sitecore modules\Shell\PowerShell

Interface Configuration

Colors

The Console, ISE, and Result dialog all provide a way a way to view output data. The $host variable provides access to configuring the colors for this output data.

Example: The following configures colors for the background and forground text in multiple streams.

$Host.UI.RawUI.BackgroundColor = ($bckgrnd = 'DarkRed')
$Host.UI.RawUI.ForegroundColor = 'Cyan'
$Host.PrivateData.WarningForegroundColor = 'Magenta'
$Host.PrivateData.WarningBackgroundColor = "Green"
$Host.PrivateData.VerboseForegroundColor = 'Green'
$Host.PrivateData.VerboseBackgroundColor = "Red"
Write-Host " Write-Host "
Write-Verbose " Write-Verbose " -Verbose
Write-Warning " Write-Warning "
Show-Result -Text -Width 500 -Height 300

Help

There are multiple methods of accessing help documentation in SPE to provide you with information on the commands available to you.

Viewing all available commands

A report is available which will show you all available SPE commands:

When executed, this report provides a paged view of the SPE commands.

Viewing command help

Console

To display the available help for a command in the Console, simply use the Get-Help command:

For full documentation, including examples, use the -Full parameter:

ISE

Through the Integrated Scripting Environment (ISE), SPE provides a method of acccessing help for available commands. To view the help for a command, simply highlight the command and press Ctrl + Enter.

After doing this, a dialog will appear with the relevant help information:

Documenting functions

When writing scripts, you are able to include formatted comments that will be used to provide help text for functions. If formatted correctly, this help text will be available through the methods described above.

Example: A simple function with documentation:

Once the script containing this function has been invoked, the help text will be available:

Online appendix

Scripting

The Integrated Scripting Environment (ISE) is a great way to group together commands and save for later use. This tool helps you write scripts in Powerful Ways!

Let's have a quick walk through of each ribbon tab available.

Home Tab

  • Write:

    • New - Creates a new script or module.

    • Open - Opens an existing script for the library.

    • Save - Saves the current script to the library.

    • Save As - Saves a copy of the current script to the library.

    • Reload - Opens the original copy of the current script without saving any modifications.

  • Script Execution:

    • Execute - Runs the current script as a background job or in the HttpContext.

    • Selection - Runs the selected text of the current script.

    • Debug - Runs the current script with the debugging mode enabled. A temporary file is generated on the file system to support the use of breakpoints.

    • Abort - Stops the execution of an executing script.

  • Context:

    • Context - Specifies the current item in the script. Helpful if you write a script dependent on a specific path, or the current directory is denoted as a . (dot) or _$pwd (_present working directory). An MRU and tree view are provided for choosing a path.

    • Session - Specifies the session to use when executing the script. Reused sessions live in the HttpSession. Options include the session created for the ISE instance, One-Time session, or the Persistent Session ID configured on the script.

  • UI Context:

    • Language - Specifies the context language to use when executing the script.

    • User - Specifies the context user to impersonate when executing the script. This can be used to emulate UserSwitcher code.

Settings Tab

  • Preferences:

    • Settings - This is where you configure the Console and ISE font family, font size, and other useful things.

  • Integration:

    • Rebuild All - This is where you rebuild the integration points for Control Panel, Gutters, and Ribbons. Without running this you will not see those integrations appear (or disappear).

Plugins Tab

The plugins feature is a great way to add custom behaviors while in the ISE. Any plugin added can make use of the Enable or Show rules to control how it appears in the ribbon.

  • Platform: Custom scripts added to the ISE Plugins integration point script library will appear here.

The Open dialog provides both a search and tree view of the scripts stored in the script libraries.

Shortcuts

Below are the shortcuts available in the ISE.

Interactive Dialogs

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.

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.

User Input

Example: The following displays an input dialog for text.

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

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.

Supported Parameter Values

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.

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

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.

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.

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.

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.

Example: The following displays a simple file browser dialog.

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

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.

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.

Console

The Console is a command line interface (CLI) designed for efficiency, providing a streamlined tool for working with Windows PowerShell and Sitecore.

Shortcuts

Below are the shortcuts available in the console.

Note: The font family, font size, and other settings can be configured through the ISE.

Meet the prerequisites found

SPE uses Unicorn for serializing Sitecore items to the source folder, and for syncing items from disk into Sitecore. For more information on Unicorn, see

For more rapid development, you can enable junction deployment on your sites. When this is enabled, rather than copying over the static files, will be setup for various folders so that the folders within the Sitecore installation are directly linked to the source folder. Any changes made in the solution are seen instantly, because the solution and the site are referencing the exact same files.

For further information on comment-based help, refer to the .

Online help is additionaly available for all SPE commands in this documentation, with detailed explanations of commands and their parameters, along with useful examples. These can be found in the .

The default security configuration for SPE requires the ISE to be in an before executing scripts. The following figure shows the ISE when the User Account Controls (UAC) are disabled. While this is a common configuration for developers, we highly encourage you to ensure UAC is enabled in higher environments.

For more commands built into the script editor see

Button Name
Return Value
Button Name
Return Value
Button Name
Return Value
Key
Type
Description
Example
Button Name
Return Value
Button Name
Return Value
Button Name
Return Value
Button Name
Return Value

The default security configuration for SPE requires the Console to be in an before allowing the execution of commands. The following figure shows the Console when the User Account Controls (UAC) are disabled. While this is a common configuration for developers, we highly encourage you to ensure UAC is enabled in higher environments.

here
https://github.com/kamsar/Unicorn
junction points
Get-Help Get-Rendering
Get-Help Get-Rendering -Full
<#
    .SYNOPSIS 
    A short synopsis of this function.
    .DESCRIPTION
    A much more detailed description of this function, which outputs a value.
    .PARAMETER Value
    The value that will be output 
    .EXAMPLE
    PS> Output-Value "My value"
    My value
#>
Function Output-String
{
    param(
        [string]$value
    )

    Write-Host $value
} 
Get-Help Output-String

Shortcut

Usage

TAB

Indent

Ctrl-Space

Autocomplete commands. Use the up or down direction keys to cycle through options.

Ctrl-Enter

Displays the command help window.

Ctrl-Z

Undo the previous change.

Ctrl-Alt-Shift +

Increase the font size

Ctrl-Alt-Shift -

Decrease the font size

Ctrl-E

Executes the script

Alt-E

Executes the selected text in the script

Ctrl-D

Debugs the script

Ctrl-Shift-E

Aborts the running script

Ctrl-F

Search for keywords in the script

Show-Alert -Title "SPE is great!"
Show-Confirm -Title "Click OK to acknowledge SPE is great!"

OK

yes

Cancel

no

Show-Input "Please provide 5 characters at most" -MaxLength 5

OK

< user input >

Cancel

$null

$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
$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

OK

ok

Cancel

cancel

< variables >

< selection >

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

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

< first button >

btn_0

< second button >

btn_1

< third button >

btn_2

Receive-File (Get-Item "master:\media library\Files") -AdvancedDialog
Get-Item -Path "master:\media library\Files\readme" | Send-File
Get-Item "master:\content\home" | Show-FieldEditor -Name "*" -PreserveSections

OK

ok

Cancel

cancel

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"

OK

< selected file >

Cancel

undetermined

Show-ModalDialog -HandleParameters @{
    "h"="FileBrowser";
} -Control "FileBrowser" -Width 500

OK

< selected file >

Cancel

undetermined

Show-ModalDialog -Control "SetIcon"
Get-Item -Path master:\* | Show-ListView -Property Name, DisplayName, ProviderPath, TemplateName, Language
for($i = 0; $i -lt 10; $i++) {
    Write-Verbose "Index = $($i)" -Verbose
}

Show-Result -Text

Shortcut

Usage

Enter

Submits line for execution.

Tab

Autocomplete commands. Press tab again to cycle through commands.

Shift+Tab

Reverse cycle through Autocomplete commands.

Shift+Enter

Inserts new line. Works when the backtick is used.

ArrowUp/Ctrl+P

Show previous command from history

ArrowDown/Ctrl+N

Show next command from history

Delete/backspace

Remove one character from right/left to the cursor

ArrowLeft/Ctrl+B

Move cursor to the left

ArrowRight/Ctrl+F

Move cursor to the right

Ctrl+ArrowLeft

Move cursor to previous word

Ctrl+ArrowRight

Move cursor to next word

Ctrl+A/Home

Move cursor to the beginning of the line

Ctrl+E/End

Move cursor to the end of the line

Ctrl+K/Alt+D

Remove the text after the cursor

Ctrl+H

Remove character before the cursor

Ctrl+D/Delete

Remove character selected by the cursor

Ctrl+C/Escape

Remove all text in the line

Ctrl+U

Remove the text before the cursor

Ctrl+V/Shift+Insert

Insert text from the clipboard

Ctrl+Alt+Shift +

Increase the font size

Ctrl+Alt+Shift -

Decrease the font size

PageUp

Scroll console up

PageDown

Scroll console down

Ctrl+R

Reverse search history

official PowerShell documentation
Command Appendix
Elevated Session State
here
Elevated Session State

Control Panel

Administration

Note: Examples included in the following modules

  • System Maintenance

Analytics

Database

Globalization

Preferences

Reports

Note: Examples included in the following modules

  • System Maintenance

Security

Item Languages

Add Language Version

Example: The following example queries all of the content items and adds a new language version of "en-ca", while overwriting any that exist.

Get-ChildItem "master:\content" -Recurse | 
    Add-ItemLanguage -Language "en-us" -TargetLanguage "en-ca" -IfExist OverwriteLatest

Example: The following example adds a language version from English to US and Polish while leaving the Title field blank. If a version already exists nothing happens.

$languageParameters = @{
    Path = "master:\content\home"
    Language = "en"
    TargetLanguage = @("pl-pl","en-us")
    IfExist = "Skip"
    IgnoredFields = @("Title")
}
Add-ItemLanguage @languageParameters

Example: The following example adds a language version from English to Polish of Template Name Sample Item. If the version exists a new version is created for that language. Finally the results are displayed as a table showing only the Name, Language, and Version.

Get-ChildItem "master:\content\home" -Language "en" -Recurse |
    Where-Object { $_.TemplateName -eq "Sample Item" } |
    Add-ItemLanguage -TargetLanguage "pl-pl" -IfExist Append |
    Format-Table Name, Language, Version -AutoSize

Example: The following example adds a language version in Polish to the Home item and all its children. If the version exists nothing happens. No fields were harmed in the making of this version.

Add-ItemLanguage -Path "master:\content\home" -TargetLanguage "pl-pl" -IfExist Skip -DoNotCopyFields -Recurse

Remove Language Version

Example: The following example queries all of the content items and removes the language version of "fr-CA".

Get-ChildItem "master:\content" -Recurse | 
    Remove-ItemLanguage -Language "fr-CA"

New Item with Forced Language Version

Example: The following example creates a new item with language versions only matching the specified languages; all other language version are removed.

$itemPath = "master:\content\home\sample item\Sample Item 3"
New-Item -Path $itemPath -ItemType "Sample/Sample Item" -Language "en-CA"

Name          Children Language Version Id                                     TemplateName
----          -------- -------- ------- --                                     ------------
Sample Item 3 False    en-CA    1       {C9517583-3AF9-4AFB-B247-BB0A09F55D94} Sample Item

Parameters and Configuration

Supported parameters:

  • -Recurse Translates item and its children

  • -IfExist Accepts one of 3 pretty self explanatory actions: Skip, Append or OverwriteLatest

  • -TargetLanguage accepts a list of languages that should be created

  • -DoNotCopyFields creates a new version but does not copy field values from original language

  • -IgnoredFields list of fields that should not be copied over from original item this can contain e.g. __Security if you don't want the new version to have the same restrictions as the original version.

On top of the ignored fields in the -IgnoredFields the following fields are ignored as configured within the Spe.config file:

<configuration xmlns:patch="https://www.sitecore.net/xmlconfig/">
  <sitecore>
    <powershell>
      <translation>
        <ignoredFields>
          <field>__Archive date</field>
          <field>__Archive Version date</field>
          <field>__Lock</field>
          <field>__Owner</field>
          <field>__Page Level Test Set Definition</field>
          <field>__Reminder date</field>
          <field>__Reminder recipients</field>
          <field>__Reminder text</field>
          <!--field>__Security</field-->
        </ignoredFields>
      </translation>
  </sitecore>
</configuration>

References

Variables

There are several variables available out of the box for use in running commands and scripts. Many of the variables prefixed with Sitecore derive from the Sitecore.config settings. Run the command Get-Variable to see the complete list available in the currently running session.

Variable

Example

AppPath

C:\Inetpub\wwwroot\Console\Website\

HostSettings

... FontSize : 12 FontFamily : Wingdings ...

me

sitecore\admin

PWD

master:\

PSScript

$PSScript.Appearance.Icon # Returns the icon of the executing script

ScriptSession

... ID : e9fedd64-cad0-4c43-b950-9cd361b151fd ...

SitecoreAuthority

SitecoreContextItem

$SitecoreContextItem.Language.Name # Returns the language name

SitecoreDataFolder

C:\Inetpub\wwwroot\Console\Data

SitecoreDebugFolder

C:\Inetpub\wwwroot\Console\Data\debug

SitecoreIndexFolder

C:\Inetpub\wwwroot\Console\Data\indexes

SitecoreLayoutFolder

C:\Inetpub\wwwroot\Console\Website\layouts

SitecoreLogFolder

C:\Inetpub\wwwroot\Console\Data\logs

SitecoreMediaFolder

C:\Inetpub\wwwroot\Console\Website\upload

SitecorePackageFolder

C:\Inetpub\wwwroot\Console\Data\packages

SitecoreScriptRoot

master:\system\Modules\PowerShell\Script Library\Task Management\Toolbox

SitecoreCommandPath

master:\system\Modules\PowerShell\Script Library\Task Management\Toolbox\Task Manager

SitecoreSerializationFolder

C:\Inetpub\wwwroot\Console\Data\serialization

SitecoreTempFolder

C:\Inetpub\wwwroot\Console\Website\temp

SitecoreVersion

8.2.160729

Note: Any new variables created are stored within the current session; when the session ends the variables are removed. Be careful not to overwrite the built-in variables.

Working with Items

Command Introduction

The majority of scripts written with SPE contain one or more of the following commands:

  • Use this to retrieve a single item. Throws an error if the item does not exist.

  • Use when Sitecore query: or fast: is required. May return more than 1 item.

Get-Item -Path "master:\content\home"
  • Use to return an item's children and grandchildren.

Get-ChildItem -Path "master:\content\home" -Recurse
  • Use to create an item based on a specified data template.

New-Item -Path "master:\content\home" -Name "Demo" -ItemType "Sample/Sample Item"
# or
New-Item -Path "master:\content\home" -Name "Demo" -ItemType "{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}"
  • Use to delete or recycle an item.

  • Accepts items returned by Get-Item and Get-ChildItem.

Get-Item -Path "master:\content\home\delete-me" | Remove-Item
  • Use to transfer an item from one location to another.

Move-Item -Path "master:\content\home\Demo" -Destination "master:\content\home\Demo1"
  • Use to duplicate an item from one location to another.

# Add -PassThru to output the new item
Copy-Item -Path "master:\content\home\Demo1" -Destination "master:\content\home\Demo2"

Command Parameters

Parameter Name

Description

Copy-Item

Get-Item

Get-ChildItem

Move-Item

New-Item

Remove-Item

AmbiguousPaths

More than one item matches the criteria so show them all.

–

✓

-

–

–

–

Database

The specified database will be used. Requires the ID to be set.

–

✓

–

–

–

–

DestinationItem

Parent item to receive the copied item.

✓

–

–

✓

–

–

FailSilently

Unauthorized access errors will be suppressed

✓

–

–

✓

–

✓

ForceId

Forces the new item to use a specified GUID

–

–

–

–

✓

–

ID

Matches the item by ID.

–

✓

✓

–

–

–

Item

Instance item.

✓

–

✓

✓

–

✓

Language

Specifies the languages to include.

–

✓

✓

–

✓

–

Parent

Specifies the parent item.

–

–

–

–

✓

–

Permanently

Specifies the item should be deleted rather than recycled.

–

–

–

–

–

✓

Query

Matches the items by an XPath query.

–

✓

–

–

–

–

StartWorkflow

Initiates the default workflow, if any.

–

–

–

–

✓

–

TransferOptions

Options flag used when copying from one database to another.

✓

–

–

✓

–

–

Uri

Matches the item by ItemUri.

–

✓

–

–

–

–

Version

Specifies the version to include.

–

✓

✓

–

–

–

WithParent

Specifies the command should include the parent item.

–

-

✓

–

–

–

Legend: "–" - not applicable; "✓" - available.

Below we will show how to use each command with the Windows PowerShell syntax followed by some examples of the common C# equivalent.

Finding Items

Get-Item : by Path

Example: The following will retrieve the item based on the Sitecore path.

PS master:\> Get-Item -Path master:\content\home

Name Children Languages                Id                                     TemplateName
---- -------- ---------                --                                     ------------
Home True     {en, de-DE, es-ES, pt... {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} Sample Item

As you may have noticed, the /sitecore portion of the path is unnecessary. This is because the Sitecore item is represented by the root item of the drive master: and is therefore optional.

Let's have a look at the equivalent code in C#.

Sitecore.Data.Database master = Sitecore.Configuration.Factory.GetDatabase("master");
Sitecore.Data.Items.Item item = master.GetItem("/sitecore/content/home");

The above will return the latest version of the item in your current language. But what if you want the item in another language? No problem!

Example: The following will retrieve the Danish version of the Home item.

PS master:\> Get-Item -Path master:/content/home -Language da | Format-Table -Property DisplayName, Language, Id, Version, TemplateName

DisplayName Language ID                                     Version TemplateName
----------- -------- --                                     ------- ------------
Hjem        da       {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 1       Sample Item

I've formatted the output above to show you that indeed the right language was returned. The command supports wildcards for both -Language and -Version parameters. You may have also noticed that the forward and backward slashes can be used interchangeably.

Example: The following retrieves the latest version for all languages of an item.

PS master:\> Get-Item -Path master:/content/home -Language * | Format-Table -Property DisplayName, Language, Id, Version, TemplateName

DisplayName Language ID                                     Version TemplateName
----------- -------- --                                     ------- ------------
Home        en       {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 1       Sample Item
Home        de-DE    {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 1       Sample Item
Home        pl-PL    {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 1       Sample Item
Home        en-US    {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 3       Sample Item
Home        en-GB    {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 1       Sample Item
Hjem        da       {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 1       Sample Item

Notice that the item with language en-US at its third version.

Example: The following retrieves the item in all languages and versions.

PS master:\> Get-Item -Path master:/content/home -Language * -Version *| Format-Table -Property DisplayName, Language, Id, Version, TemplateName

DisplayName Language ID                                     Version TemplateName
----------- -------- --                                     ------- ------------
Home        en       {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 1       Sample Item
Home        de-DE    {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 1       Sample Item
Home        pl-PL    {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 1       Sample Item
Home        en-US    {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 1       Sample Item
Home        en-US    {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 2       Sample Item
Home        en-US    {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 3       Sample Item
Home        en-GB    {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 1       Sample Item
Hjem        da       {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 1       Sample Item

You can see that specifying the language and version using the wildcard will retrieve all possible variants of an item. The wildcard can also include a partial match like en-*. The use of that filter would return all items in the English language, ignoring the region.

Get-ChildItem : by Path

Example: The following retrieves the child items in all languages and versions.

PS master:\> Get-ChildItem -Path master:/content -Language * -Version * | Format-Table -Property DisplayName, Language, Id, Version, TemplateName

DisplayName         Language ID                                     Version TemplateName
-----------         -------- --                                     ------- ------------
Home                en       {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 1       Sample Item
Home                de-DE    {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 1       Sample Item
Home                pl-PL    {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 1       Sample Item
Home                en-US    {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 1       Sample Item
Home                en-US    {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 2       Sample Item
Home                en-US    {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 3       Sample Item
Home                en-GB    {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 1       Sample Item
Hjem                da       {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 1       Sample Item

Get-Item : Sitecore query

It's not always most efficient to operate on items by traversing the tree using Get-ChildItem. This is especially true if you need to work on large trees but need to select only a few items (e.g. a specific template). For this we’ve introduced support for the Sitecore query within our provider.

Important to note that the query format sometimes requires the use of a # before and after paths when they contain reserved keywords or spaces.

Example: The following retrieves all items beneath the path /sitecore/content/ with the template of Sample Item.

PS master:\> Get-Item -Path master: -Query "/sitecore/content//*[@@templatename='Sample Item']"

Name                             Children Languages                Id                                     TemplateName
----                             -------- ---------                --                                     ------------
Copy of Home                     True     {en, de-DE, es-ES, pt... {503713E5-F9EE-4847-AEAF-DD13FD853004} Sample Item
Home                             True     {en, de-DE, es-ES, pt... {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} Sample Item

Example: The following retrieves all items beneath the path /sitecore/content/ with the template of Sample Item in all versions and languages.

PS master:\> Get-Item -Path master: -Query "/sitecore/content//*[@@templatename='Sample Item']" -Language * -Version * | Format-Table -Property DisplayName, Language, Id, Version, TemplateName -AutoSize

DisplayName  Language ID                                     Version TemplateName
-----------  -------- --                                     ------- ------------
Home         de-DE    {503713E5-F9EE-4847-AEAF-DD13FD853004} 1       Sample Item
Hjem         da       {503713E5-F9EE-4847-AEAF-DD13FD853004} 1       Sample Item
Home         en       {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 1       Sample Item
Home         de-DE    {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 1       Sample Item
Home         pl-PL    {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 1       Sample Item
Home         en-US    {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 1       Sample Item
Home         en-US    {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 2       Sample Item
Home         en-US    {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 3       Sample Item
Home         en-GB    {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 1       Sample Item
Hjem         da       {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} 1       Sample Item

Example: The following retrieves items matching the query with a specified ISO date and present in a report dialog.

$isoDate = [Sitecore.DateUtil]::ToIsoDate([datetime]::Today)
Get-Item -Path master: -Query "/sitecore/content/home//*[@__Publish > '$($isoDate)']" | 
    Show-ListView -Property ID,Name,ItemPath

Get-Item : Sitecore Fast query

Example: The following returns items with a specific template under a given root using Fast query.

$rootItemId = "{839085D0-C279-47C6-83C9-9CC28E7C111E}"
$rootItem = Get-Item -Path "master:" -ID $rootItemId
$templateId = "{759BA7B1-A216-467E-A37C-2B8D7F1A713C}"

$query = "fast:$($rootItem.ItemPath)//*[@@templateid='$($templateId)']"
Get-Item -Path "master:" -Query $query

Get-Item : by XPath

Example: The following retrieves items matching an XPath query.

$query = "ancestor-or-self::*[@@templatename='Sample Item']"

# Retrieve the items with Axes and a given context item.
$SitecoreContextItem.Axes.SelectItems($query)

# Retrieve the items using the Query class and context item.
# Retrieve the items by prepending the context path to the query.
Get-Item -Path "master:" -Query ("$($SitecoreContextItem.Paths.Path)/$query")

Get-Item : by Id

Example: The following retrieves an item by id.

PS master:\> Get-Item -Path master: -ID "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}"

Name  Children Languages                Id                                     TemplateName
----  -------- ---------                --                                     ------------
Home  True     {en, de-DE, es-ES, pt... {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} Sample Item

Get-Item : by Uri

The Uri encodes the language and version within the path.

Example: The following retrieves an item by uri.

PS master:\> Get-Item -Path master: -Uri "sitecore://master/{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}?lang=en&ver=1"

Name Children Languages                Id                                     TemplateName
---- -------- ---------                --                                     ------------
Home True     {en, de-DE, es-ES, pt... {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} Sample Item

In all the examples you'll notice we specified the database. Windows PowerShell needs to know which provider to execute within. This also signals to SPE to show the dynamic parameters. Other examples of providers include the following:

  • HKLM: - The registry provider for HKEY_LOCAL_MACHINE.

  • C: - The filesystem provider for the C drive.

Get-Item : select properties

The following examples make use of custom PropertySet for the command Select-Object.

Example: The following uses the PSSecurity PropertySet.

PS master:\ >Get-Item -Path "master:\content\home" | Select-Object -Property PSSecurity

Name ID                                     __Owner        __Security
---- --                                     -------        ----------
Home {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} sitecore\admin au|sitecore\michael|pe|+item:read|

Example: The following uses the PSTemplate PropertySet.

PS master:\> Get-Item -Path "/sitecore/media library/Images/SPE/kitten1" | Select-Object -Property PSTemplate

Name    ID                                     BaseTemplate
----    --                                     ------------
kitten1 {E58FA823-3CAF-43A1-A5ED-FBE24D3C21B4} {Image, File, Standard template, Media classification...}

Example: The following uses the PSImage PropertySet.

PS master:\> Get-Item -Path "/sitecore/media library/Images/SPE/kitten1" | Select-Object -Property PSImage

Name      : kitten1
ID        : {E58FA823-3CAF-43A1-A5ED-FBE24D3C21B4}
Alt       : Yay
Width     : 225
Height    : 225
Extension : jpg
Size      : 6593

Example: The following uses the PSSchedule PropertySet.

PS master:\> Get-Item -Path "/sitecore/system/Tasks/Schedules/Content Testing/Calculate Statistical Relevancy" | Select-Object -Property PSSchedule 

Name     : Calculate Statistical Relevancy
ID       : {C7533E65-A1D6-4F99-9F12-0AB157299D80}
Schedule : 1900101|19000101|127|1.00:00
Last run : 1/1/0001 12:00:00 AM
Command  : {6A79C206-0CD2-4DDD-9DFF-5BF21E002931}
Items    :

Get-Item : properties with field type

Example: The following accesses the Image field casted to the type Sitecore.Data.Fields.ImageField.

$item = Get-Item -Path "master:\content\home"
$item._.Image.Alt

Note: You can use ._ and .PSFields to gain access to the typed field.

Example: The following accesses the Link field casted to the type Sitecore.Data.Fields.LinkField. From there you can see all of the available properties.

PS master:\> $currentItem = Get-Item -Path 'master:\content\home\sample-item'
PS master:\> $currentItem.PSFields."LinkFieldName"

Anchor       :
Class        :
InternalPath : /sitecore/content/home/sample-item/
IsInternal   : True
IsMediaLink  : False
LinkType     : internal
MediaPath    :
QueryString  :
Target       :
TargetID     : {263293D3-B1B3-4C2C-9A75-6BD418F376BC}
TargetItem   : Sitecore.Data.Items.Item
Text         : CLICK HERE
Title        :
Url          :
Root         : link
Xml          : #document
InnerField   : <link linktype="internal" text="CLICK HERE" querystring="" target="" id="{263293D3-B1B3-4C2C-9A75-6BD418F376BC}" />
Value        : <link linktype="internal" text="CLICK HERE" querystring="" target="" id="{263293D3-B1B3-4C2C-9A75-6BD418F376BC}" />

Example: The following finds all of the TextFields and outputs to the console.

$item = Get-Item -Path "master:\content\home"
foreach($field in $item.Fields) {
    $item.PSFields."$($field.Name)" | 
        Where-Object { $_ -is [Sitecore.Data.Fields.TextField] }
}

Editing Items

Get-Item : then change item properties

We often see the following two ways of accessing and changing fields used in scripts. One uses Set-ItemProperty and the other is more natural to a Sitecore developer.

Example: The following sets the title property using Set-ItemProperty.

PS master:\> Set-ItemProperty -Path master:/content/home -Name "Title" -Value "New Title"

Example: The following sets the title and clears the branch id using .Editing.BeginEdit and .Editing.EndEdit methods.

$item = Get-Item master:/content/home
$item.Editing.BeginEdit()
$item["Title"] = "New Title"
$item.BranchId = [Guid]::Empty # or a new value if changing it
$item.Editing.EndEdit()

Note: The above example may also be written in the ISE where no console prompt is visible.

The previous examples work but are not the most efficient ways to change item content. The items returned by the provider expose the Sitecore item fields as automatic PowerShell properties.

If the property name on the data template contains a space, such as `Closing Date`, then you will need to wrap the field name in quotes (single or double).

Example: The following sets the title property using the automated PowerShell property.

$item = Get-Item -Path master:/content/home
$item.Title = "New Title"
$item."Closing Date" = [datetime]::Today

Example: The following changes the display name of the item.

$item = Get-Item -Path "master:" -ID "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}"
$item."__Display name" = "I Like Turtles"

This technique may be used for a wide variety of property types.

If you need to dynamically reference a property via a property name that is stored in a variable, there are numerous ways to reference it.

Example:

$item = Get-Item -Path "master:" -ID "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}"
$fieldName = "__Display name"

# All variations will work
Write-Host ($item.$fieldName)
Write-Host ($item."$fieldName")
Write-Host ($item."$($fieldName)")

There are a other hidden gems in automated PowerShell properties. For example, if we detect that the field is a Date or Datetime field, we will return System.DateTime typed value from a field rather than the System.String Sitecore stores internally.

Example: The following gets the created date.

$item = Get-Item -Path "master:" -ID "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}"
$item.__Created 

# Monday, April 07, 2008 1:59:00 PM

Example: The following assigns a System.DateTime value to the PowerShell automated property.

$item = Get-Item -Path "master:" -ID "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}"
$item.__Created = [DateTime]::Now
$item.__Created

# Tuesday, March 17, 2020 12:00:00 PM

Great we've just changed it! Our property handlers take care of all the necessary usages of .Editing.BeginEdit and .Editing.EndEdit. This method can be applied for a variety of field types such as GeneralLink and Image.

To provide an example – I’ve extended my home with additional fields as follows:

Example: The following assigns an image to the Image field.

$homeItem = Get-Item -Path "master:/content/home"
$homeItem.Image = Get-Item -Path "master:\media library\logo"

Easy enough, isn't it? Let SPE detect the field type for you and worry about what to call! Now let's assign a content item to GeneralLink.

Example: The following assigns a content item to a GeneralLink field.

$homeItem = Get-Item -Path "master:/content/home"
$homeItem.GeneralLink = Get-Item -Path "master:\content\home-away-from-home"

What about fields that accept lists of items? We've got your back here as well.

Example: The following assigns all children of /sitecore/content/ item to the ItemList field.

$homeItem = Get-Item -Path "master:/content/home"
$homeItem.ItemList = Get-ChildItem -Path 'master:\content\'

Let's see how our item looks in the Content editor after all the assignments that we've just performed:

Great! Looks like it worked.

Those little improvements make your scripts much more succinct and understandable. Try it for yourself!

When not to use the automated properties?

As with every rule there is an exception to this one. Those automated properties perform the $item.Editing.BeginEdit() and $item.Editing.EndEdit() every time which results in saving the item after every assignment. Assigning multiple properties on an item this way might be detrimental to the performance of your script. In such cases you might want to call $item.Editing.BeginEdit() yourself before modifying the item. Subsequently call the $item["field name"] = "new value" for each property modify. Finally end with the $item.Editing.EndEdit().

Choosing this way is situational and will usually only be required if you're working with a large volume of data. In those cases you might also want to introduce the Sitecore.Data.BulkUpdateContext technique.

Example: The following sets multiple properties while using the Sitecore.Data.BulkUpdateContext.

New-UsingBlock (New-Object Sitecore.Data.BulkUpdateContext) {
    foreach($item in Get-ChildItem -Path "master:\content\home") {
        $item.Editing.BeginEdit()
        $item["Title"] = "Sample Item"
        $item["Text"] = "Sample Item"
        $item.Editing.EndEdit() > $null
    }
}

Example: The following generates a relative url to the specified site and assigns to a variable. Because the New-UsingBlock command creates a new closure, you need to return the data to use in a different scope.

$site = [Sitecore.Sites.SiteContextFactory]::GetSiteContext("usa")
$relativeUrl = New-UsingBlock (New-Object Sitecore.Sites.SiteContextSwitcher $site) {
    $pageItem = Get-Item -Path "master:" -Id "{50BE527C-7241-4613-A7A9-20D0217B264B}"
    [Sitecore.Links.LinkManager]::GetItemUrl($pageItem)
}

Some other classes you may want to use with the New-UsingBlock function:

  • Sitecore.SecurityModel.SecurityDisabler

  • Sitecore.Data.BulkUpdateContext

  • Sitecore.Globalization.LanguageSwitcher

  • Sitecore.Sites.SiteContextSwitcher

  • Sitecore.Data.DatabaseSwitcher

  • Sitecore.Security.Accounts.UserSwitcher

  • Sitecore.Data.Items.EditContext

  • Sitecore.Data.Proxies.ProxyDisabler

  • Sitecore.Data.DatabaseCacheDisabler

  • Sitecore.Data.Events.EventDisabler

Sitecore API

If you have reached this point, then you are clearly a nerd and want to access using the raw Sitecore API.

Example: The following queries all descendants of the media library, filters by size, and wraps with automatic properties.

# Get the root node using Get-Item, then a call to Axes.
$mediaItemContainer = Get-Item -Path "master:/media library"
$items = $mediaItemContainer.Axes.GetDescendants() | 
    Where-Object { [int]$_.Fields["Size"].Value -gt 100000 } | Initialize-Item

Copying Items

Copy-Item : to a new destination

You will find yourself one day in need of copying items on a small to large scale. The Copy-Item command will likely meet the need.

Example: The following copies the item to the specified path with a new ID.

Copy-Item -Path "master:\content\home\Sample Item\Sample Item 1" -Destination "master:\content\home\Sample Item\Sample Item 2"

Note: The item name will match just as you type it in the command. Lowercase name in the destination will result in an item with a lowercase name.

Example: The following transfers the item to the specified path with the same ID.

Copy-Item -Path master:\content\Home -Destination web:\content\home -TransferOptions 0

Example: The following copies an entire tree of items and maintains the tree structure.

$sourceId = "{AF27FAD3-2AF0-4682-9BF7-375197587579}"
$destinationId = "{53F94442-555B-4622-B813-A16ED2CAB01B}"
$children = Get-ChildItem -Path "master:" -ID $sourceId
foreach($child in $children) {
    $child | Copy-Item -Destination $destinationId -Recurse
}

Moving Items

Move-Item : to a new destination

There is a always a better way to do something. Moving items en masse is certainly one that you don't want to do by hand. If the destination item exists the moved item will be added as a child. If the destination item does not exist the source item will be renamed when moved.

Example: The following moves the item from one parent to another.

Move-Item -Path "master:\content\home\sample item\Sample Item 1" -Destination "master:\content\home\sample item 2\"

Example: The following gets an item and moves to a new parent node, along with all the children.

Get-Item -Path "master:" -ID "{65736CA0-7D69-452A-A16F-2F42264D21C5}" | 
    Move-Item -Destination "master:{DFDDF372-3AB7-45B1-9E7C-0D0B27350439}"

Creating Items

New-Item

Example: The following creates a new item with the specified template.

$itemPath = "master:\content\home\sample item\Sample Item 3"
New-Item -Path $itemPath -ItemType "Sample/Sample Item"

Name                             Children Languages                Id                                     TemplateName
----                             -------- ---------                --                                     ------------
Sample Item 3                    False    {en}                     {F6F4F7B7-5E72-4C16-9294-218D80ED89E8} Sample Item

Example: The following creates a new item with the specified template id and id.

$itemPath = "master:\content\home\sample item\Sample Item 4"
$templateId = "{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}"
$itemId = "{9459ADDD-4471-4ED3-A041-D33E559BD321}"
New-Item -Path $itemPath -ItemType $templateId  -ForceId $itemId

Name                             Children Languages                Id                                     TemplateName
----                             -------- ---------                --                                     ------------
Sample Item 4                    False    {en}                     {9459ADDD-4471-4ED3-A041-D33E559BD321} Sample Item

Example: The following creates a new item as a child of the specified item.

$templateId = "{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}"
$parentItem = Get-Item -Path "master:\" -ID "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}"
New-Item -Parent $parentItem -Name "Sample Item 3" -ItemType $templateId


Name          Children Language Version Id                                     TemplateName
----          -------- -------- ------- --                                     ------------
Sample Item 3 False    en       1       {2F71043A-C731-4EC2-BFE4-0604D4D71652} Sample Item

Note: The New-Item command was passed to Format-Table -Autosize to improve the formatting.

Removing Items

Remove-Item : permanently

Example: The following removes the item permanently. Proceed with caution.

Remove-Item -Path "master:\content\home\sample item\Sample Item 3" -Permanently

References

Providers

You can interact with the providers typically available in the standard Windows PowerShell Console. Below are some of the important providers. Run the command Get-PSProvider to see the complete list.

  • FileSystem - Supports interacting with files and folders.

  • CmsItemProvider - Supports interacting with the Sitecore content items.

The console prompt typically begins with PS master:\>. The present working directory is using the CmsItemProvider and set to the master database.

Example: Change directories between providers.

 PS master:\> cd core:
 PS core:\> cd C:
 PS C:\windows\system32\inetsrv> Set-Location -Path master:
 PS master:\>

Modules

Sitecore PowerShell Extensions provides an organization structure composed of modules, libraries, and scripts. Modules make up the highest level and can be grouped together by module folders.

Some benefits to using modules:

  • Organization of custom scripts is a cinch.

The Platform module is one you should avoid changing.

Create a custom module

Getting started with your own module is a short process and something you should do for all of your custom scripts.

  1. Navigate to the Script Library item and Insert -> PowerShell Script Module.

  2. Enter the name for the new module and click OK.

  3. Right click the new module and Scripts -> Create libraries for integration points.

  4. Select the appropriate integration points for your module.

  5. Select the module and enable for use.

  6. Open the ISE, switch to the Settings tab, and rebuild integrations.

Libraries and Scripts

Modules may contain PowerShell Script Library items and PowerShell Script items. The following section outlines some of the basic concepts you need to know for the following chapters.

PowerShell Script Library

The library items represent a collection of scripts, and may be structured with one or more levels of libraries.

Naming Convention

You'll find that with the Integration Points some libraries should be created with specific names (i.e. Content Editor, Control Panel).

As a best practice we recommend that the Functions library consist of reusable scripts containing PowerShell functions (i.e. Do-Something) while other libraries contain the solution specific scripts (i.e. MakeScriptingGreatAgain).

Example: The following demonstrates the use of the Functions script library containing Get-DateMessage.

Some names we've used included:

  • Beginner Tutorials

  • Content Editor

  • Content Maintenance

  • Content Interrogation

  • Development

  • Event Handlers

  • Functions

  • Internal

  • Page Editor

  • Pipelines

  • Profile and Security

  • Reports

  • Script Testing

  • Tasks

  • Toolbox

  • User Interaction

  • Web API

Many of the libraries are integration points for the module. When the integration point wizard runs, you will see that these can be generated automatically.

Fields

Interactive : The following fields support the two custom rules as well as a variety of out-of-the-box rules.

  • ShowRule (Show if rules are met or not defined) - typically controls visibility of integration points.

    • PowerShell

      • where specific persistent PowerShell session was already initiated

      • where specific persistent PowerShell session was already initiated and has the specific variable defined and not null

      • where exposed in a specific view

    • PowerShell ISE

      • when length script length is compares to number characters long

      • when the edited script is in a state

  • EnableRule (Enable if rules are met or not defined) - typically controls enabled state of integration points.

    • Same as above

Rules Usage

There are a number of use cases for the EnableRule and ShowRule.

  • If there is a UI component the ShowRule can be used to ensure it appears while the EnableRule can toggle when it can be clicked.

  • If there is no UI component, the EnableRule is used to determine when the script should be executed; useful to limit creation of PowerShell runspaces.

PowerShell Script

The script items represent the code that will be executed.

Naming Convention

There are three conventions that we recommend you follow which are shown with an example below.

  • Title Casing - This should be used when the name will be exposed in places such as the Content Editor, script library names, and Reports root directory.

  • Sentence casing - This should be used when the name is long and will not be visible to the user or is a report with a very long name.

  • Noun-Verb - This should be used when the script is stored within the Functions script library and will be imported using the command Import-Function.

Fields

Scripting

  • Script (Script body) : This is a multi-line text than should be edited using the PowerShell ISE application.

Session Persistency

  • PersistentSessionId (Persistent Session ID) : Context scripts using this ID will execute in a single session and be reused; leaving empty will cause the session to be discarded after execution. This value should be used for rules requesting the session ID.

Integration Points

The SPE Modules support a wide variety of predefined script libraries to help with exposing scripts to the Sitecore interface.

The following list outlines the available libraries for Integration Points that may be added to modules. These may also be generated automatically when creating or updating modules.

Be certain to enable the module when you need to use it.

    • Context Menu - Visibility can be control using rules made available from within the Interactive field section.

    • Insert Item - Visibility can be control using rules made available from within the Interactive field section.

    • Warning - Appears as a warning message beneath the ribbon in the Content Editor.

  • Internal

    • List View - Represents the ribbon buttons such as for Actions and Exports.

    • Notification - Appears as a notification message beneath the ribbon in the Experience Editor.

    • LoggedIn

    • LoggingIn

    • Logout

Other Integrations

Syncing Integrations

The section on provided a variety of examples in retrieving items based on their language. In this section will show how to manage items and their languages.

The following commands provide you with the core methods needed to manage your content. Due to the nature of Windows PowerShell, commands such as these are extended with custom parameters and switches using . These parameters are then added to the command at the time of use and only appear when the conditions are right. We've provided this table to help you discover the hidden gems within each command.

If you have retrieved your items directly using the Sitecore API you can still add the nice wrapper. You can do that by piping them through the Initialize-Item command. We'll show an of this later.

Check out some performance details when using different methods of querying items on the .

Workaround found .

The setup is not exactly like you would find in the XPath Builder but should get the job done. Read more about it .

Extended Sample Item
ItemList Assignment

Note: Include the backslash in the path (i.e. **C:**) to get the root of the drive when interacting with the FileSystem provider; the behavior seen is different than you might expeect because of w3wp.exe. See issue #.

The contained within each module can be enabled or disabled globally. For this to take full affect the integration should be rebuilt in the ISE.

More reasons can be found in Adam's .

ShowRule
EnableRule

Interactive : Refer to the description shown for PowerShell Script Library .

Gutters - Requires the library to be .

Ribbon - Requires the library to be . Visibility can be control using rules made available from within the Interactive field section.

- Requires the library to be .

- Not a formal integration point library, but a good place to add scripts used for Data Source Scripts. Read more about how they work and . The Source field simply references the script like script:/sitecore/system/Modules/PowerShell/Script Library/[MODULE NAME]/Data Sources/[SCRIPT NAME].

- Requires a patch file to enable the desired events. Read more about it .

- Exposes scripts to the command Import-Function.

- Appears as a button in the ISE Settings tab.

(Experience Editor)

- Appears as a shortcut under Sitecore -> Reporting Tools -> PowerShell Reports.

- Appears as a shortcut under Sitecore -> Toolbox. Visibility can be control using rules made available from within the Interactive field section.

- Not a formal integration point library, but a good place to add scripts used for Scheduled Tasks. SPE includes a PowerShellScriptCommand found under /sitecore/system/Tasks/Commands/PowerShellScriptCommand which is used to run scripts from within scheduled tasks.

- Exposes scripts than can be consumed through . The script can be executed by requesting a specific url.

- Not a formal integration point library, but a good place to add scripts used for Workflow Action Scripts. Read more about how they work .

Remoting - Interact with SPE through the provided web services as described . A Windows PowerShell module is made available to encapsulate the web service calls into PowerShell commands.

Some integrations need to be synced with the Core database through the ISE. See the section of the Scripting documents for instructions.

working with items
Issue 184
Remove All Content items in French
Dynamic Parameters
Sitecore StackExchange
here on Sitecore Stack Exchange
here
Working with Sitecore Items in PowerShell Extensions
314
example
# /sitecore/system/modules/powershell/script library/spe rocks/functions/get-datemessage
function Get-DateMessage {
  "The current date and time is: $(Get-Date)"
}
# /sitecore/system/modules/powershell/script library/spe rocks/alerts/show-datemessage
Import-Function -Name Get-DateMessage

Show-Alert (Get-DateMessage)
https://console
integration points
post
Content Editor
Data Sources
here
here
Event Handlers
here
Functions
ISE Plugins
Page Editor
Pipelines
Reports
Toolbox
Tasks
Web API
SPE Remoting
Workflows
here
here
Settings
fields
synced (see below)
synced (see below)
Control Panel
synced (see below)

ISE Plugin

ISE Plugin

Reports List View Action

Reports List View Action

Reports List View Export

Reports List View Export

Content Editor

Visual components made available to users in the Content Editor.

Context Menu

The Context Menu integration reveals a list of options to the user in the context menu under a special node called Scripts. The Sitecore rules engine may be used to control visibility and enabled state. The script is only executed when the option is clicked.

  1. Begin by adding a new script to the Context Menu library. The name of the script will appear in the context menu.

  2. Edit the script to perform the appropriate actions. The script can run in the background and show dialogs.

  3. Change the icon of the item to match the script purpose.

  4. Configure any Enable or Show rules as needed.

Note: Examples included in the following modules

  • Authoring Instrumentation

  • Copy Renderings

  • Index On Demand

  • Media Library Maintenance

  • Package Generator

  • Task Management

Gutter

The Gutter integration reveals a visual notification to the user in the far left gutter. The Sitecore rules engine may be used to control enabled state.

  1. Begin by adding a new script to the Gutters library.

  2. Edit the script to create a new instance of Sitecore.Shell.Applications.ContentEditor.Gutters.GutterIconDescriptor if the right conditions are met.

    • Set the Icon, Tooltip, and Click properties.

    • Return the gutter object

  3. Configure any Enable rules to ensure the script runs only when necessary.

  4. Rebuild the gutter integration from within the ISE.

    • Settings tab

    • Integration chunk

    • Sync Library with Content Editor Gutter command

Note: Examples included in the following modules

  • Publishing Status Gutter

Insert Item

The Insert Item integration reveals a list of options to the user in the context menu under the node called Insert. The Sitecore rules engine may be used to control visibility and enabled state. The script is only executed when the option is clicked.

  1. Begin by adding a new script to the Insert Item library. The name of the script will appear in the context menu.

  2. Edit the script to perform the appropriate actions. The script can run in the background and show dialogs.

  3. Change the icon of the item to match the script purpose.

  4. Configure any Show rules as needed.

Note: Examples included in the following modules

  • Task Management

  • Platform

Ribbon

The Ribbon integration reveals commands to the user in the ribbon. The Sitecore rules engine may be used to control visibility and enabled state. The script is only executed when the option is clicked.

  1. Begin by adding a new child script library to the Ribbon library; we'll refer to this library as the Tab library. Choose a name that matches an existing tab to be used, such as Home or Developer, or a new name to create a new tab.

  2. Add a child script library to the Tab library; we'll call this the Chunk library. Choose a name such as Edit or Tools.

  3. Add a new script to the Chunk script library; we'll refer to this library as the Command library. The name of the script will appear in the ribbon chunk as a command.

  4. Optionally add a short description on the item, which is found as a standard field on the item. The description will appear as a tooltip on the ribbon button.

  5. Edit the script to perform the appropriate actions. The script can run in the background and show dialogs.

  6. Change the icon of the item to match the script purpose.

  7. Configure any Enable or Show rules as needed.

Example: The following script gets the selected Context Menu item and displays an alert using the item name.

# Use the notation "." to get the current directory/item.
$item = Get-Item -Path .
Show-Alert -Title $item.Name

Button Size:

There is a way to generate small buttons and combo buttons. You simply need to prefix the script name and SPE will generate accordingly.

  • Small$[SCRIPT_NAME]

  • Combo$[SCRIPT_NAME]

  • SmallCombo$[SCRIPT_NAME]

Contextual Ribbon

Similar to the Ribbon integration, this provides a way to show buttons when certain contextual conditions are met. Most common is with media items. The steps are the same as with the standard Ribbon, but the structure is slightly changed.

In the following example, we have a ribbon button that appears whenever the selected item in the Content Editor is a media item. Take note of the "Optimize" button.

The ribbon structure would look like the following:

Warning

The Warning integration reveals a notification to the user above content. The Sitecore rules engine can be used to control visibility and enabled state. The scripts are only executed when the rule is met and the command is clicked.

  1. Begin by adding a new script library to the Warning library.

  2. Edit the script to perform the appropriate actions. The script can run in the background and show dialogs.

  3. The warning notification title, text and icon should be configured in the script.

    • Include options to the warning by adding one or more secondary scripts to the script library.

  4. Configure any Enable rules to ensure the script only runs when required.

Note: Examples included in the following modules

  • License Expiration - disabled by default

Functions

The Functions integration allows for scripts to be discoverable through autocomplete while authoring scripts. Functions can be "disabled" by disabling the containing module.

  1. Begin by adding a script library called "Functions" to a module. This can be created by the new module wizard.

  2. Add a script to the "Functions" script library with a name that represents the purpose.

  3. Use the command Import-Function to discover the available functions.

Note: It's best practice to create function scripts that follow the Verb-Noun pattern as outlined by Microsoft.

Here's a short video on authoring custom functions.

Page Editor

Notification

The Notification integration reveals to the user a notification above the content. The Sitecore rules engine may be used to control the enabled state; simply configure the Enable rule on the script. The script is executed every time the page loads.

Example: The following adds an information notification to the page for Sitecore 8 and a warning for Sitecore 7.

$title = "Thank you for using SPE!"
$text = "Today is $([datetime]::Now.ToLongDateString())"
$icon = @{$true="Office/32x32/information.png";$false="Applications/16x16/warning.png"}[$SitecoreVersion.Major -gt 7]

$notification = New-Object -TypeName Sitecore.Pipelines.GetPageEditorNotifications.PageEditorNotification -ArgumentList $text, "Info"

$notification.Icon = $icon
$pipelineArgs.Notifications.Add($notification)

Note: Examples included in the following modules

  • License Expiration

Experience Button

The Experience Button integration adds a button to the Page Editor. Rules can be used to control visiblity and enablement. The script is only executed when the button is clicked.

  1. Begin by adding a new script to the Experience Button library. The name of the script will appear in the tooltip.

  2. Edit the script to perform the appropriate actions. The script can run in the background and show dialogs.

  3. Change the icon of the item to match the script purpose.

  4. Configure any Enable or Show rules as needed.

Example: The following adds a command which will display a dialog asking a question, then send an email with the response.

$item = Get-Item -Path .
$response = Show-Input -Prompt "What's the message for $($item.Name)?"
if($response) {
    $mailSettings = @{
        To = @("Michael West < mw@test.com >")
        From = "Console < noreply@test.com >"
        BodyAsHtml = $true
        SmtpServer = "localhost"
    }

    $subject = "Message sent regarding item $($item.Name) from $($SitecoreAuthority)"
    $response += "<br/>$($item.ItemPath)"
    Send-MailMessage @mailSettings -Subject $subject -Body $response
}

Close-Window

ISE Plugins

Custom ribbon commands for use in the ISE.

You can include custom ribbon commands in the ISE to aid in improving the script authoring experience.

Add a custom plugin

For this example, we wish to have a plugin that analyzes the script and reports on any errors.

Create a new script stored under the following structure:

The path structure needs to follow [MODULE]/Internal/ISE Plugins/[PLUGIN_NAME]. Here we have X-Demo/Internal/ISE Plugins/Analyze Script.

Use the following sample to fill in the script body.

if([string]::IsNullOrWhiteSpace($scriptText)){
    Show-Alert "Script is empty - nothing to format."
    exit
}

Import-Module -Name PSScriptAnalyzer
Invoke-ScriptAnalyzer -ScriptDefinition $scriptText

Now you can run the command from the ribbon and see the results in the ISE.

Event Handlers

The Event Handler integration provides a way to execute scripts when defined events are fired.

Steps required to activate this integration include the following:

  1. Enable the Spe.Events.config or apply your own patch with the required events enabled.

  2. Add a new integration point library to your new or existing module.

  3. Add a new script to the appropriate event library.

  4. Configure an Enable Rule if needed.

  5. Profit!

Enable Configuration

While SPE comes with an example configuration, which is disabled by default, it contains several events that may not meet your requirements.

An event configuration patch may look like the following:

<configuration xmlns:patch="https://www.sitecore.net/xmlconfig/">
  <sitecore>
    <events>
      <event name="item:added">
        <handler type="Spe.Integrations.Tasks.ScriptedItemEventHandler, Spe" method="OnEvent" />
      </event>
    </events>
  </sitecore>
</configuration>

Add Event Script

To mimic the event item:added you should create nested script libraries such as Event Handlers -> Item -> Added followed by a script.

Tasks

The task scheduler is a great way to run scripts in a periodic fashion. You may find the need to automatically archive log files into a compressed file. Perhaps send an email with a generated report based on stale site content.

Video Tutorial

Scheduled Task Command

To help make the setup simple, we've provided a Task Command.

The command shown above is simply a type exposed as a public method in the Spe assembly. There exists an update method which accepts one or more items and executes the associated script.

Beneath Schedules you can create as many tasks as Sitecore will allow. Configure the Command and Items fields like that shown below.

The Items field contains the path to a script in the Script Library.

Below are some of the scripts found out-of-the-box with SPE.

Create and Manage Tasks

We've added a context menu item to provide you with a shortcut to the Task Scheduler Editor.

Create a new scheduled task:

Run or edit the scheduled task:

The scheduled task is capable of running 1-to-many scripts. Choose all that apply for the selected task. Each script runs within a shared session, making it possible to share results between scripts.

Note: Make use of the Enable Rule to take advantage of the rules engine.

The task schedule has an intuitive dialog for working with and changing the frequency.

Note: Examples included are in the following modules

  • License Expiration

  • Media Library Maintenance

  • System Maintenance

Content Editor

Content Editor

Content Editor

Content Editor

Content Editor

Content Editor

Content Editor

Page Editor

Page Editor

See how Adam added .

See the birth of by Adam.

Check out an example of the in the wild by Toby.

Contextual Ribbon Command
Script Library Structure

Alan provided a nice example on setting up the warning with commands.

Creating Functions

ISE Plugins
Analyze Script
Example results

See how Adam added .

DataSources
Event Handlers
Reports
Reports
Pipelines
Tasks
Toolbox
Workflow Action
context menu PowerShell scripts
extending the Sitecore ribbon with powershell scripts
5 steps to extending the Sitecore ribbon
here
Click for a demo
Context Menu
Context Menu
Gutter
Insert Item
Ribbon
Ribbon
Warning
Notification
Experience Button

Module

Script

System Maintenance

Archive Sitecore logs, Clean up deleted items older than 30 days

User Session Management

Remove idle user sessions

Click for a demo
powershell driven Sitecore scheduled tasks

Reports

The reports which come out of the box provide a wide variety of information regarding your Sitecore installation.

Running a Report

The custom reports can be found by navigating to Sitecore -> Reporting Tools -> PowerShell Reports.

As an example, let's run the Unused media items report.

Once the report completes, the results appear in a report window.

Reports in SPE like ASR

While SPE contains many reports, they don't match identical to ASR reports. We've done our best to build those that seem most relevant or likely to be used. If you find a report in ASR that you would like to exist in SPE please submit a request.

SPE Report

ASR Report

Active Aliases

Aliases

Audit

Broken Links2

Broken Links

Broken Links in publishable items

Item History

Items with Invalid Names

Items with security for an account2

Items with Security for an account

Items with Tokens in Fields

Links

Locked Items2

Locked Items

Logged errors

Logged in Session Manager5

Logged in Users

Limit number of versions4

Multiple versions

My Owned Items

Media items last updated before date3

Not recently modified

Media items not used by content items3

Orphaned media assets report

Owned items

Recent workflow history2

Recent Workflow History

Media items last updated after date3

Recently Modified

Regex Item Searcher

Renderings

Index Viewer5

-

Rules based report5

-

Task Manager report5

-

Check the reports in SPE under these sections to see the full list.

  • 1 Configuration Audit report

  • 2 Content Audit report

  • 3 Media Audit report

  • 4 Solution Audit report

  • 5 Toolbox

Note: Examples included are in the following modules

  • Content Reports

Reports Security

You may wish to expose the reports to users such as Content Authors. Here are the steps required to grant access to users in the sitecore\Sitecore Client Authoring role.

Here is what users may see in the event they do not have the appropriate access.

  1. Navigate to the item /sitecore/content/Documents and settings/All users/Start menu/Right/Reporting Tools/PowerShell Reports

  2. Grant access to sitecore\Sitecore Client Authoring

  3. Verify the reports are now visible to the Authoring users.

Note: In verson 6.4 the default access changed from sitecore\Sitecore Client Maintaining to a lower privileged account sitecore\Sitecore Client Authoring.

Authoring Tasks

The Sitecore task scheduler is capable of running PowerShell scripts when using the task command PowerShellScriptCommand. The Task Management module includes a few shortcuts to managing tasks.

The module provides the ability to create, edit, and run scheduled tasks.

References

Data Sources

Scripted Data Sources provide a way to use a PowerShell script to perform complex queries.

Here are some good reasons to use this feature:

  • Delivering complex functionality based on multiple criteria.

  • Your field may need to provide different set of items to choose from based on:

    • user name or role (in simplest case this can be done using right management, but maybe not always possible in a more elaborate scenario)

    • current day or month?

    • In a multisite/multimarket scenario you may want to show different items for each site

      based on engagement analytics parameters of the page

      based on where in the tree an item exist (some of it can be done with use of a “query:”)

    • anything you might want to build the code data source for…

Something that would be beyond the reach of a regular Sitecore query and potentially something that you would really need to deliver code source for. But maybe you’re not in a position to deploy that on your environment?

Field Data Source

Field Data Source provides a great opportunity for a script.

Below are field types you may wish to use a script:

  • Checklist

  • Droplist

  • Grouped Droplink

  • Grouped Droplist

  • Multilist

  • Name Lookup Value List

  • Droplink

  • Begin by adding a new script library called Data Sources followed by adding a script. You can call it something like Get-GlobalOption.

  • Add the path to your script in the Source field on the data template. The source should be prefixed with script: followed by the path.

  • Enjoy the results.

Rendering Data Source Roots

//TODO

Rendering Data Source Items

//TODO

References

Scheduled Task Editor

We've built quite a few reports, many similar to the (ASR) module.

PowerShell Scripted Data Sources and

Sitecore Spark on using scripted datasources

Advanced System Report
Custom Scheduled Task by Mike Reynolds
# The script must return an item. This is useful for populating a Droplink.
Get-ChildItem -Path "master:" -ID "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}"
script:/sitecore/system/Modules/PowerShell/Script Library/X-Demo/Data Sources/Get-GlobalOption
part 1
part 2
article

Workflows

The Workflows integration allows for scripts to run like workflow commands. Rules can be used to control visiblity and enablement. The script is only executed when the command is triggered.

  1. Begin by adding a new item to a workflow command of template type /Modules/PowerShell Console/PowerShell Script Workflow Action. We've added an insert option to help with this.

  2. Edit the Type string field to your custom type or to the built in type Spe.Integrations.Workflows.ScriptAction, Spe.

  3. Edit the Script body with the appropriate script. I like to save my workflow scripts in a library called Workflows.

  4. Configure the Enable rules on the workflow action item to specify when to execute. Leave the rule alone if you wish for it to execute any time the command is activated.

  5. Edit the script in your Workflows library to perform the appropriate actions. The script can run in the background and show dialogs.

  6. Change the icon of the workflow action item to match the script purpose.

  7. Celebrate your success with the team!

Example: The following requests input from the user then writes to the workflow history.

$item = $SitecoreContextItem
$comment = Show-Input -Prompt "Enter a comment:"
if($comment) {
    New-ItemWorkflowEvent -Item $item -Text $comment
}
Close-Window

References

Packaging

Ever wanted to package up items and files without opening the Sitecore Package Designer each time? There are a number of commands available for generating packages.

Package Creation

Example: The following example demonstrates how to generate a package.

Post Step

Example: The following adds a Post Step and custom attributes.

Example: The following adds a Post Step included with SPE to delete a file. The SPE Post Step code reads xml data stored in the comment section of the package.

Example: The following adds a Post Step Script included with SPE to change icons. The SPE Post Step code executes a script included with the package as stored in the attributes section.

Remoting

There are a number of use cases where you need to remotely run scripts within SPE. Here we will try to cover a few of those use cases.

Remoting Automation Service

We have provided a handy way of executing scripts via web service using the Remoting Automation Service.

Remoting Module Setup

The setup of the module only requires a few steps: 1. In the Sitecore instance install the Sitecore module package. 2. On the local desktop or server install the SPE Remoting module.

  • After downloading you may need to unblock the file by right-clicking the zip and unblocking.

  • Ensure that you have run Set-ExecutionPolicy RemoteSigned in order for the SPE Remoting module will run. This typically requires elevated privileges.

Windows Authenticated Requests

If you have configured the web services to run under Windows Authentication mode in IIS then you'll need to use the Credential parameter for the commands.

You'll definitely know you need it when you receive an error like the following:

Example: The following connects Windows PowerShell ISE to a remote Sitecore instance using Windows credentials and executes the provided script.

Example: The following connects to several remote instances of Sitecore and returns the server name.

File and Media Service

Example: The following downloads a single file from the Package directory.

Example: The following downloads a single media item from the library.

Script Sessions and Web API Tutorial

Advanced Script Sessions

Inevitably you will need to have long running processes triggered remotely. In order to support this functionality without encountering a timeout using Invoke-RemoteScript you can use the following list of commands.

  • Get-ScriptSession - Returns details about script sessions.

  • Receive-ScriptSession - Returns the results of a completed script session.

  • Remove-ScriptSession - Removes the script session from memory.

  • Start-ScriptSession - Executes a new script session.

  • Stop-ScriptSession - Terminates an existing script session.

  • Wait-ScriptSession - Waits for all the script sessions to complete before continuing.

These commands are not only used for remoting, we just thought it made sense to talk about them here.

Example: The following remotely runs the id of a ScriptSession and polls the server until completed.

Example: The following remotely runs a script and checks for any output errors. The LastErrors parameter is available for ScriptSession objects.

Example: The following improves upon the previous example.

Troubleshooting

If you receive the following error when trying to run a script (note the namespace is Microsoft.PowerShell.Commands instead of Spe or similar):

then add the following line as the first line within the Invoke-RemoteScript block: Set-Location -Path "master:"

Example:

This issue occurs due to the fact that the remoting session defaults to the FileSystem provider. Changing the location activates the custom provider included with SPE. As part of the custom provider there are additional parameters added to commands native to PowerShell.

References

See how Adam integrated if you are really curious to know more.

Enable the remoting service through a configuration patch. See the page for more details.

Grant the remoting service user account through a configuration patch and granting acess to the appropriate role. See the page for more details.

The remoting services use a combination of a SOAP service (ASMX) and HttpHandler (ASHX). Remoting features are disabled by default and should be configured as needed as can be seen in the . The SOAP service may require additional Windows authentication using the -Credential parameter which is common when logged into a Windows Active Directory domain.

We have provided a service for downloading all files and media items from the server. This disabled by default and can be enabled using a patch file. See the page for more details about the services available and how to configure.

Example: The following redirects messages from Write-Verbose to the remote session. The data returned will be both System.String and Deserialized.System.Management.Automation.VerboseRecord so be sure to filter it out when needed. More information about the redirection 4>&1 can be read .

Michael's follow up post on

Adam's initial post on

workflow actions
Fixing problematic content or Workflow state
$package = New-Package "Package-of-Stuff"
$package.Sources.Clear()

$package.Metadata.Author = "Michael West"
$package.Metadata.Publisher = "Team Awesome"
$package.Metadata.Version = "1.0"
$package.Metadata.Readme = @"
Set of instructions for the user.
"@

# Items using New-ItemSource and New-ExplicitItemSource
$source = Get-Item -Path "master:\templates\Feature\Forms" | 
    New-ItemSource -Name 'Feature Forms Items' -InstallMode Overwrite
$package.Sources.Add($source)

# Files using New-FileSource and New-ExplicitFileSource
$source = Get-Item -Path "$AppPath\App_Config\Include\Feature\Forms\Company.Feature.Forms.config" | 
    New-ExplicitFileSource -Name "Feature Forms Files"
$package.Sources.Add($source)

Export-Package -Project $package -Path "$($package.Name)-$($package.Metadata.Version).xml"
Export-Package -Project $package -Path "$($package.Name)-$($package.Metadata.Version).zip" -Zip
Download-File "$SitecorePackageFolder\$($package.Name)-$($package.Metadata.Version).zip"
$package = New-Package "Package-of-Stuff"
$package.Sources.Clear()

$package.Metadata.Author = "Michael West"
$package.Metadata.Publisher = "Team Awesome"
$package.Metadata.Version = "1.0"
$package.Metadata.Readme = @"
Set of instructions for the user.
"@
$package.Metadata.PostStep = "Some.Library.Class,Some.Library"
$package.Metadata.Attributes = "scriptId={9b9a3906-1979-11e7-8c9d-177c30471cec}|width=50|height=200"

Export-Package -Project $package -Path "$($package.Name)-$($package.Metadata.Version).xml"
Import-Function -Name New-PackagePostStep

$package = New-Package "Package-of-Stuff"
$package.Sources.Clear()

$package.Metadata.Author = "Michael West"
$package.Metadata.Publisher = "Team Awesome"
$package.Metadata.Version = "1.0"
$package.Metadata.Readme = @"
Set of instructions for the user.
"@
$newPackageFiles = @([PSCustomObject]@{"FileName"="/bin/Company.Feature.Unused.dll"})
$package.Metadata.PostStep = "Spe.Package.Install.PackagePostStep, Spe.Package"
$package.Metadata.Comment = New-PackagePostStep -PackageFiles $newPackageFiles
$package = New-Package "Package-of-Stuff"
$package.Sources.Clear()

$package.Metadata.Author = "Michael West"
$package.Metadata.Publisher = "Team Awesome"
$package.Metadata.Version = "1.0"
$package.Metadata.Readme = @"
Set of instructions for the user.
"@
$package.Metadata.PostStep = "Spe.Integrations.Install.ScriptPostStep, Spe"
$package.Metadata.Attributes = "scriptId={737CD0CC-12F7-4528-8FBD-E0FDEFC41325}"
Write-Log "Processing changes to ensure backwards compatibility."
$oldVersion = New-Object System.Version(10,0)
if($PSVersionTable["SitecoreVersion"] -lt $oldVersion) {
    $iseButton = Get-Item -Path "core:{bfc79034-857c-4432-a5c2-2d93af784384}"
    $iseButton.Editing.BeginEdit()
    $iseButton.Fields["{D25B56D4-23B6-4462-BE25-B6A6D7F38E13}"].Value = "powershell/32x32/ise8.png"
    $iseButton.Editing.EndEdit() > $null

    $reportButton = Get-Item -Path "core:{74744022-353c-43f1-b8e4-5bc569ca9348}"
    $reportButton.Editing.BeginEdit()
    $reportButton.Fields["{D25B56D4-23B6-4462-BE25-B6A6D7F38E13}"].Value = "Office/32x32/chart_donut.png"
    $reportButton.Editing.EndEdit() > $null
    Write-Log "Changes complete."
} else {
    Write-Host "No changes required."
}
Close-Window
New-WebServiceProxy : The request failed with HTTP status 401: Unauthorized.
Import-Module -Name SPE
$credential = Get-Credential
$session = New-ScriptSession -Username admin -Password b -ConnectionUri https://remotesitecore -Credential $credential
Invoke-RemoteScript -Session $session -ScriptBlock { Get-User -id admin }
Stop-ScriptSession -Session $session

# Name                     Domain       IsAdministrator IsAuthenticated
# ----                     ------       --------------- ---------------
# sitecore\admin           sitecore     True            False
# If you need to connect to more than one instance of Sitecore add it to the list.
$instanceUrls = @("https://remotesitecore","https://remotesitecore2")
$session = New-ScriptSession -Username admin -Password b -ConnectionUri $instanceUrls
Invoke-RemoteScript -Session $session -ScriptBlock { $env:computername }
Stop-ScriptSession -Session $session
Import-Module -Name SPE
$session = New-ScriptSession -Username admin -Password b -ConnectionUri https://remotesitecore
Receive-RemoteItem -Session $session -Path "default.js" -RootPath App -Destination "C:\Files\"
Stop-ScriptSession -Session $session
Import-Module -Name SPE
$session = New-ScriptSession -Username admin -Password b -ConnectionUri https://remotesitecore
Receive-RemoteItem -Session $session -Path "/Default Website/cover" -Destination "C:\Images\" -Database master
Stop-ScriptSession -Session $session
Import-Module -Name SPE
$session = New-ScriptSession -Username admin -Password b -ConnectionUri https://remotesitecore
$jobId = Invoke-RemoteScript -Session $session -ScriptBlock {
        "master", "web" | Get-Database | 
            ForEach-Object { 
                [Sitecore.Globals]::LinkDatabase.Rebuild($_)
            }
} -AsJob
Wait-RemoteScriptSession -Session $session -Id $jobId -Delay 5 -Verbose
Stop-ScriptSession -Session $session
$jobId = Invoke-RemoteScript -Session $session -ScriptBlock {
    Get-Session -ParameterDoesNotExist "SomeData"
} -AsJob
# This delay could actually be that you got up to get some coffee or tea.
Start-Sleep -Seconds 2

Invoke-RemoteScript -Session $session -ScriptBlock {
    $ss = Get-ScriptSession -Id $using:JobId
    $ss | Receive-ScriptSession

    if($ss.LastErrors) {
        $ss.LastErrors
    }
}
Invoke-RemoteScript -ScriptBlock {
    Write-Verbose "Hello from the other side" -Verbose 4>&1
    "data"    
    Write-Verbose "Goodbye from the other side" -Verbose 4>&1
} -Session $session
Invoke-RemoteScript -ScriptBlock {
    function Write-Verbose {
        param([string]$Message)
        Microsoft.PowerShell.Utility\Write-Verbose -Message $Message -Verbose 4>&1
    }

    Write-Verbose "Hello from the other side"
    "data"    
    Write-Verbose "Goodbye from the other side"
} -Session $session
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.NewItemCommand
Invoke-RemoteScript -ScriptBlock {
    Set-Location -Path "master:"
    ...
    [The rest of your script]
    ...
}
Security
Security
Click for a demo
security section here
Security
Click for a demo
here
Remoting
Remoting

Security

View important details on how to keep Sitecore secure while using SPE.

You need to be mindful that Sitecore PowerShell Extensions is a very sharp tool and while it can be leveraged to do great things, it can also be a vector of dangerous attacks if not secured properly. This is why we recommend that you do not install it on Content Delivery instances and if possible avoid deploying it on servers that face Internet altogether.

Installing SPE in internet facing (DMZ) scenarios is not recommend. Please avoid installing in the Content Delivery instances. Implement a strategy which provides the least amount of access required. Consider locking down the web server to only allow connections to your databases and preapproved web services.

Security Policies

There are two main security policies to consider when using the SPE module:

  • Application Pool service account

  • Sitecore user account

Application Pool Service Account

The first policy relates to the Application Pool service account running in IIS. The Windows PowerShell runspace will have access to the local system via providers (i.e. FileSystem, Registry), and be managed through the Console or ISE. If the service account is capable of removing files from the root directory, then SPE can accomplish the same.

When using the IIS identities such as ApplicationPoolIdentity and NetworkService the scripts may have access to directories outside of the application such as the drive root; you should perform a due dilligence to make sure this is the case! You may also notice that the $HOME variable is empty; this is because only named service accounts have profiles.

The application pool service account can give SPE access to many features in the OS.

Sitecore User Account

The second policy relates to the Sitecore user account. The code executed through SPE operates within the privileges of the logged in user. Keep in mind that this can be bypassed just as can be done through the Sitecore API as PowerShell scripts can call the APIs that disable the Sitecore security.

Application Security The following settings are configured under core:\content\Applications\PowerShell.

Feature

Visibility

PowerShell Console

sitecore\Developer (read)

PowerShell ISE

sitecore\Developer (read)

PowerShell ListView

sitecore\Sitecore Client Users (read)

PowerShell Runner

sitecore\Sitecore Client Users (read)

PowerShell Reports

Note: The security is validated in each SPE application within the function OnLoad.

Menu Item Security The following settings are configured under core:\content\Applications\Content Editor\Context Menues\Default\.

Feature

Visibility

Command State

Edit with ISE

sitecore\Developer (read)

Enabled when item template is PowerShell Script otherwise Hidden

Console

sitecore\Developer (read)

Enabled when user is admin or in the role sitecore\Sitecore Client Developing otherwise Hidden

Scripts

sitecore\Sitecore Limited Content Editor (deny read)

Enabled when the service and user are authorized to execute otherwise Hidden

Note: See the Interactive section on PowerShell Script Library and PowerShell Script items for visibility and enabled rules. To hide each feature you can change the security settings for the roles that should not see the menu.

Security Hardening

The following section outlines steps you can take to minimize the surface area for attack. The following topics describe how to manage security for interfaces and services for the various parts of the module.

Session Elevation

User Account Control

Let's have a look at the configurable features which make up the UAC.

Gate

Attribute
Description

name

built-in name for the gate

token

name of the token to use for the elevated session

Token

The object which expires after a predetermined time. These can be unique to each gate or shared.

Attribute
Description

name

unique string used for the gate token attribute

expiration

timespan used to determine the elevated session lifetime (hh:mm:ss)

elevationAction

action to perform when session elevation is triggered (allow, block, password)

Actions supported out of the box:

  • Allow - Always allow the session to run elevated without prompting the user for permission. This should never be used outside of a developer's machine.

  • Block - Always block the session from running elevated without prompting the user for permission.

  • Password - Prompt the user for a password before running the session elevated, unless an unexpired session is active.

  • Confirm - Prompt the user for a confirmation before running the session elevated.

Example: The following extends the token expiration to 10 minutes and blocks the use of the Console.

<sitecore>
  <powershell>
    <userAccountControl>
      <tokens>
        <token name="Console">
          <patch:attribute name="expiration">00:10:00</patch:attribute>
          <patch:attribute name="elevationAction">Block</patch:attribute>
        </token>
        <token name="ISE">
          <patch:attribute name="expiration">00:10:00</patch:attribute>
        </token>
        <token name="ItemSave">
          <patch:attribute name="expiration">00:10:00</patch:attribute>
        </token>
      </tokens>
    </userAccountControl>
  </powershell>
</sitecore>

Gates with Password protection enabled prompt the user when no elevated session is available. When using Azure AD and or similar provider you should use the Confirm action.

Content Editor

A Content Editor Warning is displayed when a PowerShell Module, Script Library, and Script is selected. Click "Elevate session" to show the hidden fields and enable the management of the item.

The "Drop session" option appears after credentials are verified. All scripts can be edited while the session is elevated.

ISE

A warning is presented in the ISE when no elevated session state is available.

The following warning is rendered in the ISE while the session state is elevated. Click "Drop elevated session state" if you do not want to wait for the elevated session to timeout.

Configure Web Services

The web services providing external access to Sitecore are disabled by default. You can override this behavior by patching the following configuration file \App_Config\Include\Spe.config.

Look for the following section and enable as needed.

<sitecore>
  <powershell>
    <services>
      <restfulv1 enabled="false" />
      <restfulv2 enabled="false" />
      <remoting enabled="false" />
      <fileDownload enabled="false" />
      <fileUpload enabled="false" />
      <mediaDownload enabled="false" />
      <mediaUpload enabled="false" />
      <handleDownload enabled="true" />
      <client enabled="true" />
      <execution enabled="true" />
    </services>
  </powershell>
</sitecore>

Service Descriptions

  • Remoting - Used when passing scripts to SPE for execution. Enable when using the SPE Remoting module. Service associated with RemoteAutomation.asmx.

  • RESTful v2 - Used when the url contains all the information needed to execute a script saved in the SPE library. Service associated with RemoteScriptCall.ashx.

  • File Download - Used when the url contains all the information needed to download a file from the server. Enable when using the SPE Remoting module. Service associated with RemoteScriptCall.ashx.

  • File Upload - Used when the url contains all the information needed to upload a file to the server. Enable when using the SPE Remoting module. Service associated with RemoteScriptCall.ashx.

  • Media Download - Used when the url contains all the information needed to download a media item from the server. Enable when using the SPE Remoting module. Service associated with RemoteScriptCall.ashx.

  • Media Upload - Used when the url contains all the information needed to upload a media item to the server. Enable when using the SPE Remoting module. Service associated with RemoteScriptCall.ashx.

  • Handle Download - Used when a file is downloaded through the Sitecore interface. Enable when using the SPE Remoting module. Service associated with RemoteScriptCall.ashx.

  • Client - Used for the SPE Console. Service associated with PowerShellWebService.asmx.

  • Execution - Used when SPE checks if the user has access to run the application.

  • RESTful v1 - Used in early version of SPE. Avoid using this if possible. Service associated with RemoteScriptCall.ashx.

The preferred way to override the settings is through the use of a configuration patch file.

Example: The following enables the file and media downloads.

<configuration xmlns:patch="https://www.sitecore.net/xmlconfig/">
  <sitecore>
    <powershell>
      <services>
        <fileDownload>
          <patch:attribute name="enabled">true</patch:attribute>
        </fileDownload>
        <mediaDownload>
          <patch:attribute name="enabled">true</patch:attribute>
        </mediaDownload>
      </services>
    </powershell>
  </sitecore>
</configuration>

Example: The following enables the SPE Remoting service and requires a secure connection using HTTPS.

<configuration xmlns:patch="https://www.sitecore.net/xmlconfig/">
  <sitecore>
    <powershell>
      <services>
        <remoting>
          <patch:attribute name="requireSecureConnection">true</patch:attribute>
          <patch:attribute name="enabled">true</patch:attribute>
        </remoting>
      </services>
    </powershell>
  </sitecore>
</configuration>

Note: When using the attribute requireSecureConnection, you may find that this causes a 403 status code when testing against a server hosted behind a load balancer. If the load balancer maintains the TLS certificate and forwards traffic to a backend web server over port 80 .Net will not recognize this as a secure connection.

Restrict Users and Roles

Sitecore level security

You are required to explicitly grant the SPE Remoting session user account to a predefined role found in the configuration Spe.config. There is a generic list of permissions configured by default but we highly encourage you to adjust to meet your security requirements.

Example: The following configuration defines the roles that have access to use SPE Remoting. Any role previously defined in the <authorization/> section is removed and custom roles are then added.

<configuration xmlns:patch="https://www.sitecore.net/xmlconfig/">
  <sitecore>
    <powershell>
      <services>
        <remoting>
          <authorization>
            <patch:delete />
          </authorization>
          <authorization>
            <add Permission="Allow" IdentityType="Role" Identity="sitecore\PowerShell Extensions Remoting" />
          </authorization>
        </remoting>
      </services>
    </powershell>
  </sitecore>
</configuration>

Example: The following configuration grants access to custom roles without removing any existing roles.

<configuration xmlns:patch="https://www.sitecore.net/xmlconfig/">
  <sitecore>
    <powershell>
      <services>
        <remoting>
          <patch:attribute name="enabled">true</patch:attribute>
          <authorization>
            <add Permission="Allow" IdentityType="User" Identity="sitecore\test1"  desc="test1" />
            <add Permission="Allow" IdentityType="User" Identity="sitecore\test2"  desc="test2" />
          </authorization>
        </remoting>
      </services>
    </powershell>
  </sitecore>
</configuration>

Delegated Access

  • Step 2: Enter the role in which lower privileged users are members.

  • Step 3: Enter the user account with elevated access. This could be sitecore\Admin or any other user your environment has configured. This user will be impersonated during script execution.

  • Step 5: Enable the delegated access item when ready for use.

When scripts are executed you should see them logged to the SPE log where the context user and impersonated user appear.

2304 14:02:32 INFO [Gutter] Executing script {CFE81AF6-2468-4E62-8BF2-588B7CC60F80} for Context User sitecore\test as sitecore\Admin.

IIS level security

Example: The following configuration will deny anonymous calls to the web services.

<configuration>
    <system.web>
      <authorization>
        <deny users="?" />
      </authorization>
    </system.web>
</configuration>

Minimal Web Service Configuration

The following files are the bare minimum required to support SPE web services. This setup is suitable for environments such as servers built within a Continuous Integration environment that need remoting enabled. Remoting is disabled by default. If you need this functionality, enable it separately using a config patch file.

Required:

  • App_Config\Include\Spe\Spe.config

  • App_Config\Include\Spe\Spe.Minimal.config

  • bin\Spe.dll

  • bin\Spe.Abstractions.dll

  • sitecore modules\PowerShell\Services\web.config

  • sitecore modules\PowerShell\Services\RemoteAutomation.asmx

  • sitecore modules\PowerShell\Services\RemoteScriptCall.ashx

You will also need to patch the configuration with the following:

<configuration xmlns:patch="https://www.sitecore.net/xmlconfig/">
    <sitecore>
        <controlSources>
            <source mode="on" namespace="Spe.Client.Controls" assembly="Spe">
                <patch:delete />
            </source>
            <source mode="on" namespace="Spe.Client.Applications"
                  folder="/sitecore modules/Shell/PowerShell/" deep="true">
                <patch:delete />
            </source>
        </controlSources>
    </sitecore>
</configuration>

For your convenience we've included a package bundled with all of the above called SPE.Minimal-6.x.zip. Any of the disabled configuration files should be enabled following extraction.

References

Identity Server

Note: If you are using Sitecore 9.1 or later with Identity Server, there is a configuration file that should be enabled.

  • Spe.IdentityServer.config

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:security="http://www.sitecore.net/xmlconfig/security/">
  <sitecore role:require="Standalone or ContentManagement or XMCloud" security:require="Sitecore">
    <pipelines>
      <owin.cookieAuthentication.validateIdentity>
        <processor type="Sitecore.Owin.Authentication.Pipelines.CookieAuthentication.ValidateIdentity.ValidateSiteNeutralPaths, Sitecore.Owin.Authentication">
          <siteNeutralPaths hint="list">
            <!-- This entry corrects the infinite loop of ExecuteCommand in the SPE Console -->
            <path hint="spe">/sitecore%20modules/PowerShell</path>
          </siteNeutralPaths>
        </processor>
      </owin.cookieAuthentication.validateIdentity>
    </pipelines>
  </sitecore>
</configuration>

Users and Roles

Managing users and roles is a big topic and this section won't cover everything. We aim to show you different problems that have come up and how we solved them.

Example: The following command returns the security commands available.

Get-Command -Noun Role*,User,ItemAcl* | Sort-Object -Property Noun,Verb

Users

Managing users should be a pretty straight forward task. While the User Manager provided by Sitecore is handy, you'll likely find yourself wanting to make bulk changes. The following examples should give you a few ideas about how to manage user accounts.

Query users and update properties

Example: The following generates a batch of test users in the default domain with the out-of-the-box user profile template. The users are then queried filtering on the name.

foreach($num in 0..10) {
    $key = -join ((65..90) + (97..122) | Get-Random -Count 7 | % {[char]$_})  
    New-User -Identity "TestUser$($key)" -Enabled -Password "b" -ProfileItemId "{AE4C4969-5B7E-4B4E-9042-B2D8701CE214}" | Out-Null
}

Get-User -Filter "sitecore\TestUser*"

In case you forgot to set the user profile for accounts, we have a solution for that.

Example: The following queries a user and sets the profile template. Note that changing the profile template requires the user to be authenticated.

Get-User -Id "michael" -Authenticated | 
    Set-User -ProfileItemId "{AE4C4969-5B7E-4B4E-9042-B2D8701CE214}"

Example: The follow queries all the user accounts for the default provider and filters those over the age of 18. The age property is custom on the Profile. Finally, export to CSV.

$users = Get-User -Filter * | Where-Object { $_.Profile.GetCustomProperty("age") -gt 18 } 

$property = @(
    "Name",
    @{Name="Age";Expression={ $PSItem.Profile.GetCustomProperty("age") }}
)
$users | Select-Object -Property $property | 
  Export-CSV -Path "C:\temp\users-over-eighteen.csv" -NoTypeInformation

Active Directory

Using Set-User to update AD accounts may result in an "Access denied message"; this is due to the fact that the account querying user does not have write access to profile properties or the profile provider is not configured properly.

Roles

Example: The following queries roles using the specified identity.

# Identity can be "[domain]\[name]", "Creator-Owner", and "\Everyone"
Get-Role -Identity "default\Everyone"

Item Access Control Lists (ACL)

The ACL commands provide an automated way of granting privileges to items.

Example: The following creates a new ACL and assigns to an item.

$aclForEveryone = New-ItemAcl -Identity "\Everyone" -PropagationType Any -SecurityPermission DenyInheritance -AccessRight *
Get-Item -Path "master:\content\home" | Add-ItemAcl -AccessRules $aclForEveryone -PassThru

References

Troubleshooting

General

We generally see issues occurring due to an incompatible version of Windows PowerShell. Be sure to install Windows PowerShell version 3 or newer.

Installation

Elevated Session Hanging

There is an additional configuration file added to support Identity Server. If you are installing Sitecore 9.1 or later you will want to enable the configuration file Spe.IdentityServer.config.

Hanging Installation Wizard

Hack: Run this script on Sitecore 8.0.

$paths = @("C:\inetpub\wwwroot\Console\Website\App_Config\Include\*")
$patterns = @("Sitecore.Analytics*.config", "Sitecore.ExperienceAnalytics*.config")

$paths | Get-ChildItem -Include $patterns -Recurse | Rename-Item -NewName { $PSItem.Name + ".disabled" }

Exception Messages

ISE throws exception when /sitecore/content/home is missing

Modules

Integration Point is not working

Be sure the module is enabled and the integrations are rebuilt from within the ISE. The following are some of the integration issues you may experience:

  • Content Editor Gutter - Entries not listed.

  • Content Editor Ribbon - Buttons not visible or working.

  • Control Panel - Entries not listed.

  • Functions - Import-Function name parameter not populating with functions or can't be found after running the command.

  • Web API - Scripts not existing or can't be found.

Remoting

  • 404 error in browser console can be caused by missing SPE files, a custom pipeline, or perhaps a rewrite rule.

  • "The underlying connection was closed: An unexpected error occurred on a send." could be caused in Azure PaaS when requests are made using TLS 1.1 or lower. Setting the SecurityProtocol may help. Thanks to Jayesh Sheth for pointing to a resolution.

    • [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

Toolbox

The PowerShell Toolbox is quick way to access frequently used scripts.

Navigate to Sitecore -> PowerShell Toolbox and after selecting you should see the configured scripts:

Note: Examples included in the following modules

  • Authorable Reports

  • Logged in Session Manager

  • Package Generator

  • Task Management

  • Platform

Available Tools

Index Viewer

Logged in Session Manager

View the list of user sessions and "kick" them out as needed.

Rules based report

Generate a report using the Sitecore Rules Engine.

PowerShell Background Session Manager

View the list of SPE sessions and "kill" them as needed.

Create Anti-Package

Re-create Site from Sitemap

Simple tool for generating a site tree using an existing sitemap.

Task Manager

View and manage the configured scheduled tasks.

Create Tools for the Toolbox

To create your own Toolbox item take the following steps: 1. Create the Toolbox folder under an SPE module. Use the context menu to simplify the process.

  • Right click the module name and choose Scripts -> Create libraries for integration points.

  • Select the Toolbox item and click Proceed.

    1. Create a PowerShell Script under the Toolbox item.

  • Right click the Toolbox library and choose PowerShell Script.

    1. Open and edit the PowerShell Script using the ISE.

    2. Run the Rebuild All command in the ISE by navigating to the Settings tab and selecting the icon to rebuild. Be certain to enable the module before running the rebuild command.

    3. Verify the new toolbox item appears in the Toolbox.

Item Renderings

In this section we'll show how to manage item renderings.

List renderings

Example: The following demonstrates the use of Get-LayoutDevice and Get-Rendering to find all renderings on a page associated with the FinalLayout.

$defaultLayout = Get-LayoutDevice -Default
$rootItem = Get-Item -Path "master:" -ID "{961563FC-3445-4558-BF3A-06DF06BA6298}"
Get-Rendering -Item $rootItem -Device $defaultLayout -FinalLayout

Update rendering parameters

Example: The following demonstrates the use of Get-Rendering and Set-Rendering for updating values on templates.

$rendering = Get-Item -Path "master:\sitecore\layout\Sublayouts\Sample Sublayout"

$items = Get-ChildItem -Path "master:\sitecore\templates\Sample Item" -Recurse 
foreach($item in $items) {
    $renderingInstance = Get-Rendering -Item $_ -Rendering $rendering 
    if ($renderingInstance) { 
        Set-Rendering -Item $_ -Instance $renderingInstance -Parameter @{ 
            "Lorem" = "Ipsum" 
        } 
        Write-Host "Updated $($_.Paths.FullPath)" 
    } 
}

Find pages using rendering

Example: The following demonstrates how to report on pages referencing the specified rendering.

Get-Item "master:\layout\Renderings\Feature\Experience Accelerator\Page Content\Page Content" | 
    Get-ItemReferrer | Where-Object { $_.ContentPath.StartsWith("/Demo/usa/Home") } | Show-ListView

Find renderings marked cacheable

Example: The following demonstrates how to report on which renderings are globally set to "Cacheable".

Get-ChildItem -Path "master:\layout\Renderings" -Recurse | 
    Where-Object { $_.Cacheable -eq "1" } | 
    Select-Object -Property Name, Cacheable, ClearOnIndexUpdate, VaryBy* | 
    Sort-Object -Property Name | Show-ListView

Find renderings with personalization

Example: The following demonstrates how to find renderings with a conditions node set on the item.

$query = "fast:/sitecore/content//*[@__renderings='%<conditions%' or @#__Final Renderings#='%<conditions%']"
$items = Get-Item -Path "master:" -Query $query

Disable cacheable setting on renderings

Example: The following demonstrates how to disable global caching on all renderings.

$VerbosePreference = "Continue"
Get-ChildItem -Path "master:\layout\Renderings" -Recurse | 
    Where-Object { $_.Cacheable -eq "1" } | 
    ForEach-Object { Write-Verbose "Disabled global caching on $($_.Name)"; $_.Cacheable = "0" }

# VERBOSE: Disabled global caching on Navigation

Move renderings between placeholders

$placeholderMappings = @(
 @("/old-placeholder","/new-placeholder"),
 @("/another-old-placeholder","/new-placeholder")
)
$rootItem = Get-Item -Path master:/sitecore/content/Home
$defaultLayout = Get-LayoutDevice "Default"
# Toggle for whether to update Shared or Final Layout
$useFinalLayout = $True
# If set to true, the script will only list the renderings that need fixing, rather than fixing them.
$reportOnly = $False
foreach ( $item in Get-ChildItem -Item $rootItem -Recurse )
{
    # Only interested in items that have a layout
    if (Get-Layout $item)
    {
        foreach( $mapping in $placeholderMappings )
        {
            # Get renderings in this item that have renderings in the placeholder we want to update 
            $renderings =  Get-Rendering -Item $item -Placeholder ($mapping[0] + '/*') -Device $defaultLayout -FinalLayout:$useFinalLayout

            foreach ( $rendering in $renderings )
            {
                # Only update the rendering if we're not in "Report Only" mode
                if (!$reportOnly)
                {
                   # Update the placeholder in the rendering and set it back in the item
                   $rendering.Placeholder = $rendering.Placeholder -replace $mapping[0], $mapping[1]
                   Set-Rendering -Item $item -Instance $rendering -FinalLayout:$useFinalLayout
                }
                Write-Host "$($item.FullPath) - Rendering $($rendering.UniqueID) - Placeholder: $($mapping[0]) --> $($mapping[1])"
            }
        }
    }
}

Remove datasource from rendering

Example: The following removes a datasource from a rendering on the FinalLayout.

Get-Rendering -Item $item -PlaceHolder "main" | 
  Foreach-Object { Set-Rendering -Item $item -Instance $_ -DataSource $null -FinalLayout }

Replace compatible rendering

$rendering = Get-Item master:\layout\path\to\your\rendering
$renderingPageContainer = Get-Rendering -Item $item "{F39BAC93-1EEC-446B-A4A1-AB7F7C1B6267}" -Device $defaultLayout
$renderingPageContainer.ItemID = $rendering.ID
Set-Rendering -Item $item -Instance $renderingPageContainer

Further Reading

Community

See some of the community contributed modules built for SPE.

There are some really amazing contributions and add-ons to SPE from the community.

Unicorn

Configurations

Example: The following lists configurations by name.

# Default returns all configurations
Get-UnicornConfiguration

# Exact match
Get-UnicornConfiguration -Filter "Foundation.Foo"

# Filter using a wildcard
Get-UnicornConfiguration -Filter "Foundation.*"

Syncing

Example: The following syncs configurations just like you would through the Unicorn Control Panel or the PowerShell API.

# Sync one
Sync-UnicornConfiguration "Foundation.Foo"

# Sync multiple by name
Sync-UnicornConfiguration @("Foundation.Foo", "Foundation.Bar")

# Sync multiple from pipeline
Get-UnicornConfiguration "Foundation.*" | Sync-UnicornConfiguration

# Sync all, except transparent sync-enabled configurations
Get-UnicornConfiguration | Sync-UnicornConfiguration -SkipTransparent

# Optionally set log output level (Debug, Info, Warn, Error)
Sync-UnicornConfiguration -LogLevel Warn

Partial Syncing

# Sync a single item (note: must be under Unicorn control)
Get-Item "/sitecore/content" | Sync-UnicornItem

# Sync multiple single items (note: all must be under Unicorn control)
Get-ChildItem "/sitecore/content" | Sync-UnicornItem 

# Sync an entire item tree, show only warnings and errors
Get-Item "/sitecore/content" | Sync-UnicornItem -Recurse -LogLevel Warn

Reserializing

# Reserialize one
Export-UnicornConfiguration "Foundation.Foo"

# Reserialize multiple by name
Export-UnicornConfiguration @("Foundation.Foo", "Foundation.Bar")

# Reserialize from pipeline
Get-UnicornConfiguration "Foundation.*" | Export-UnicornConfiguration

Partial Reserializing

# Reserialize a single item (note: must be under Unicorn control)
Get-Item "/sitecore/content" | Export-UnicornItem

# Reserialize multiple single items (note: all must be under Unicorn control)
Get-ChildItem "/sitecore/content" | Export-UnicornItem 

# Reserialize an entire item tree
Get-Item "/sitecore/content" | Export-UnicornItem -Recurse

Converting to Raw Yaml

# Convert an item to YAML format (always uses default excludes and field formatters)
Get-Item "/sitecore/content" | ConvertTo-RainbowYaml

# Convert many items to YAML strings
Get-ChildItem "/sitecore/content" | ConvertTo-RainbowYaml

# Disable all field formats and field filtering
# (e.g. disable XML pretty printing,
# and don't ignore the Revision and Modified fields, etc)
Get-Item "/sitecore/content" | ConvertTo-RainbowYaml -Raw

Converting from Raw Yaml

# Get IItemDatas from YAML variable
$rawYaml | ConvertFrom-RainbowYaml

# Get IItemData and disable all field filters
# (use this if you ran ConvertTo-RainbowYaml with -Raw)
$yaml | ConvertFrom-RainbowYaml -Raw

Deserialization

# Deserialize IItemDatas from ConvertFrom-RainbowYaml
$rawYaml | ConvertFrom-RainbowYaml | Import-RainbowItem

# Deserialize raw YAML from pipeline into Sitecore 
# Shortcut bypassing ConvertFrom-RainbowYaml
$yaml | Import-RainbowItem

# Deserialize and disable all field filters
# (use this if you ran ConvertTo-RainbowYaml with -Raw)
$yaml | Import-RainbowItem -Raw

# Deserialize multiple at once
$yamlStringArray | Import-RainbowItem

# Complete example that does nothing but eat CPU
Get-ChildItem "/sitecore/content" | ConvertTo-RainbowYaml | Import-RainbowItem

Packaging

# Create a new Sitecore Package (SPE cmdlet)
$pkg = New-Package -Name MyCustomPackage

# Get the Unicorn Configuration(s) we want to package
$configs = Get-UnicornConfiguration "Foundation.*" 

# Pipe the configs into New-UnicornItemSource 
# to process them and add them to the package project
# (without -Project, this would emit the source object(s) 
#   which can be manually added with $pkg.Sources.Add())
$configs | New-UnicornItemSource -Project $pkg

# Export the package to a zip file on disk
Export-Package -Project $pkg -Path "C:\foo.zip" -Zip

SPE Modules

The following are Sitecore modules that enhance the SPE experience.

Field Types

Examples for managing complex field types such as MultilistField and NameValueListField.

Edit MultilistField

Example: The following demonstrates how to set a field to a known list of Ids. The Id is already converted to a GUID string.

Example: The following replaces an instance of an Id with an alternate Id. The Id is already converted to a GUID string.

Example: The following adds new Ids to an existing list. Makes use of the Sitecore.Text.ListString class.

Example: The following appends an ID to a set of items in all languages. It verifies that the field Keywords exists.

Example: The following example gets all of the items of a MultilistField and append a specific ID, ensuring that it's delimited with the | character.

Example: The following example extracts the items from a 'keywords' field, comma separates the values, and then outputs to a report.

Edit NameValueListField

Example: The following example gets all of the name/value pairs of a NameValueListField and appends a new pair.

Add-BaseTemplate

Add one or more base templates to a template item.

Syntax

Add-BaseTemplate -Item <Item> -TemplateItem <TemplateItem[]>

Add-BaseTemplate -Item <Item> -Template <String[]>

Add-BaseTemplate -Path <String> -TemplateItem <TemplateItem[]>

Add-BaseTemplate -Path <String> -Template <String[]>

Add-BaseTemplate -Id <String> -TemplateItem <TemplateItem[]>

Add-BaseTemplate -Id <String> -Template <String[]>

Add-BaseTemplate [-Database <String>]

Detailed Description

The Add-BaseTemplate command adds one or more base templates to a template item.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Item <Item>

The item to add the base template to.

-Path <String>

Path to the item to add the base template to.

-Id <String>

Id of the item to add the base template to.

-TemplateItem <TemplateItem[]>

Sitecore item or list of items of base templates to add.

-Template <String[]>

Path representing the template item to add as a base template. This must be of the same database as the item to be altered. Note that this parameter only supports a single template.

-Database <String>

Database containing the item to add the base template to - required if item is specified with Id.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Notes

Help Author: Adam Najmanowicz, Michael West, Alex Washtell

Examples

EXAMPLE 1

Add base template of /sitecore/templates/User Defined/BaseTemplate to a template, using a path.

EXAMPLE 2

Add multiple base templates to a template, using items.

Related Topics

SPE Remoting Module
SPE Web API

sitecore\Sitecore Client Authoring. See for instructions.

The bundled with the module provide convenient ways to interact with the Sitecore API. The module provides a User Account Control (UAC) feature akin to that of Microsoft Windows.

The way in which scripts make their way into Sitecore through built-in interfaces. Includes the , , and Content Editor via Item Saving.

Required for the following features: PowerShell .

Required for the following features: command. If the report export buttons do not work it could be because of this setting.

Required for the following features: PowerShell , PowerShell ,

Required for the following features: dialog, PowerShell Script Runner, (Context Menu, Insert Options, Ribbon).

There may be scenarios in which you need to grant users access to run scripts which require access to be higher the what is currently configured for the user. The various integration points made visible in the Content Editor (Context Menu, Ribbon, Reports) can be configured to run the scripts impersonating a power user. This has the advantage of giving lower privileged users "special" access without having to make members of more privileged roles. In this feature introduced a simple configuration item to apply the "special" access.

Step 1: Create a new delegated access item using the provided insert option.

Step 4: Select each script/library that should be delegated. Script/library items with a rule checking for delegated access should be included as well as scripts that should be run with the impersonated account.

Deny access to the web services for unauthenticated users and roles using the <deny> element as described in sitecore modules\PowerShell\Services\web.config.

If you disable Anonymous Authentication and enable Windows Authentication in IIS, such as the directory sitecore modules\PowerShell\Services\ you'll need to use the Credential parameter for any command that interacts with the services. See the section for examples.

When using the you may need to increase the setting LDAP.SizeLimit if you wish to return all Active Directory accounts.

You can see the Sitecore Stack Exchange answer describing the contents of the configuration.

Some users have reported an where the package installation in Sitecore hangs while installing SPE. One possible fix is to disable the Sitecore Analytics feature; this of course assumes you do not plan on using it for your instance.

Article: Martin Miles encountered the issue and proposed a fix .

- Missing Home item (fixed in 3.2)

"The request failed with an empty response." could be caused when TLS is offloaded to a load balancer and traffic to the endpoint is no longer over HTTPS. Fixed by issue #.

Toolbox

This tool provides similar functionality to the module. Search and rebuild the index on-demand.

Index Viewer
Logged in Session Manager
Rules based report
PowerShell Background Session Manager

This tool provides similar functionality to the module.

Create Anti-Package
Re-create Site from Sitemap
Task Manager

Example: The following moves renderings from one placeholder to another. .

SPE + Unicorn

A well known and widely adopted module has published some SPE commands. These commands are available (and optional) after installing Unicorn. Below are some samples ripped off from Kam Figy's blog posts and .

Example Syncing
Converting To Yaml
Converting from Yaml
Deserialization

:

:

:

:

:

Aliases
Aliases
Aliases
Aliases
Aliases
Aliases

interfaces
Console
ISE
Web API
Out-Download
Console
ISE
Download File
Content Editor
#1283
here
Remoting
Shields Down Example
Active Directory module
Using Get-User command to query over 200k users
Explore Sitecore Users Properties
here
issue
here
378
1005
Index Viewer
Sitecore Rocks
See this article for more details
Parse raw layout xml and count components
Unicorn
here
here
SPE Image Importer
Himadri Chakrabarti
Multi-Item Publish
Richard Seal
Publish Status
Morten Engel
Westco Pull Up Fields
Michael West
Westco Image Optimizer
Michael West
# Hardcoded list of Ids.
$item.Editing.BeginEdit()
$item["Allowed Controls"] = "{guid1}|{guid2}|{guid3}"
$item.Editing.EndEdit()
# Array of Ids.
$array = [System.Collections.ArrayList]@()
$array.Add({guid1}) > $null
$array.Add({guid2}) > $null
$ids = [System.String]::Join("|", $array)
$item.Editing.BeginEdit()
$item["Allowed Controls"] = $ids
$item.Editing.EndEdit()
[Sitecore.Data.Fields.MultilistField]$field = $item.Fields["Allowed Controls"]
$item.Editing.BeginEdit()
$field.Replace("{493B3A83-0FA7-4484-8FC9-4680991CF742}","{493B3A83-0FA7-4484-8FC9-4680991CF743}")
$item.Editing.EndEdit()
[Sitecore.Text.ListString]$ids = $item.Fields["Rendering"].Value
$ids.AddAt(0,"{guid1}") > $null
$ids.Add("{guid2}") > $null
$ids.Add("{guid3}") > $null

$item.Editing.BeginEdit()
$item.Fields["Rendering"].Value = $ids.ToString()
$item.Editing.EndEdit() > $null
$items = Get-ChildItem -Path "master:\sitecore\content\home" -Recurse -Language *
foreach($item in $items) {
    if ($item.Keywords -and $item.Keywords.Length -gt 0) {
        $item.Keywords = $item.Keywords + "|{guid}"
    } else {
        $item.Keywords = "{guid}"
    }
}
$items = Get-ChildItem -Path "master:\sitecore\content\home" -Recurse -Language *
foreach($item in $items) {
    $item.Keywords = (@() + $item.Keywords.GetItems().ID + "{6D1EACDD-0DE7-4F3D-B55A-2CAE8EBFF3D0}" | Select-Object -Unique) -join "|"
}
function Get-KeywordsAsString($item) {
    [Sitecore.Data.Fields.MultilistField] $field = $item.Fields["Keywords"]
    $items = $field.GetItems()
    $strArray = $items | Foreach { $_.DisplayName }
    $strArray -join ', '
}
Get-ChildItem -Path 'master:\content\home\path-to-item' `
  | Show-ListView -Property Name, Language, Version, ID, TemplateName, ItemPath, `
        @{ Label = "KeywordsAsString"; Expression = { Get-KeywordsAsString($_) } }
$item = Get-Item -Path "master:" -ID "{371EEE15-B6F3-423A-BB25-0B5CED860EEA}"

$nameValues = [System.Web.HttpUtility]::ParseQueryString($item.UrlMapping)

# Here you can add or remove name/value pairs
$nameValues["^/ab[cde]/$"] = "/somewhere/fun?lang=en"

foreach($key in $nameValues.AllKeys) {
    $nameValues[$key] = [Uri]::EscapeDataString($nameValues[$key])
}

$item.UrlMapping = [Sitecore.StringUtil]::NameValuesToString($nameValues,"&")

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

PS master:\> Add-BaseTemplate -Path "master:/sitecore/content/User Defined/Page" -Template "/sitecore/templates/User Defined/BaseTemplate"
PS master:\> $baseA = Get-Item -Path master:/sitecore/content/User Defined/BaseTemplateA
       PS master:\> $baseB = Get-Item -Path master:/sitecore/content/User Defined/BaseTemplateB
       PS master:\> Add-BaseTemplate -Path "master:/sitecore/content/User Defined/Page" -TemplateItem @($baseA, $baseB)
here
Remove-BaseTemplate
Get-ItemTemplate
Set-ItemTemplate
https://github.com/SitecorePowerShell/Console/

Common

Item Links

Examples for managing item referrers maintained by the Link Database.

Relink Item

$item = Get-Item -Path "master:\media library\images\koala"
$itemNew = Get-Item -Path "master:\media library\images\penguins"
$links = Get-ItemReferrer -Item $item -ItemLink
foreach($link in $links) {
    $linkedItem = Get-Item -Path master:\ -ID $link.SourceItemID 
    $itemField = $linkedItem.Fields[$link.SourceFieldID]
    $field = [Sitecore.Data.Fields.FieldTypeManager]::GetField($itemField)
    
    $linkedItem.Editing.BeginEdit()
    $field.Relink($link, $itemNew)
    $linkedItem.Editing.EndEdit() | Out-Null
}

Remove Item Link

# Crafted by Dylan

function Remove-ItemLink {
    param([Item]$item)
    
    $linkDb = [Sitecore.Globals]::LinkDatabase

    $links = Get-ItemReferrer -Item $item -ItemLink

    foreach($link in $links) {
        $linkedItem = Get-Item -Path master:\ -ID $link.SourceItemID 
        $itemField = $linkedItem.Fields[$link.SourceFieldID]
        $field = [Sitecore.Data.Fields.FieldTypeManager]::GetField($itemField)

        $linkedItem.Editing.BeginEdit()
        $field.RemoveLink($link)
        $linkedItem.Editing.EndEdit()
    }
}

# Example usage: delete items along with their references that have passed a certain date defined by a 'date' field
$today = Get-Date
$todayIsoDate = [Sitecore.DateUtil]::ToIsoDate($today)
$query = "/sitecore/system/Modules/Mysite/Service Schedules/*[@date < '$($todayIsoDate)']"
$itemsToDelete = Get-Item -Path master: -Query $query

foreach($item in $itemsToDelete) {
    Write-Host "Cleaning up $($itemsToDelete.Paths.Path)"
    Remove-ItemLink -Item $item
    Remove-Item -Path $item.Paths.Path
}

Add-ItemVersion

Creates a version of the item in a new language based on an existing language version.

Syntax

Add-ItemVersion [-Item] <Item> [-Recurse] [-IfExist <Append | Skip | OverwriteLatest>] [-TargetLanguage <String[]>] [-DoNotCopyFields] [-IgnoredFields <String[]>] [-Language <String[]>]

Add-ItemVersion [-Path] <String> [-Recurse] [-IfExist <Append | Skip | OverwriteLatest>] [-TargetLanguage <String[]>] [-DoNotCopyFields] [-IgnoredFields <String[]>] [-Language <String[]>]

Add-ItemVersion -Id <String> [-Database <String>] [-Recurse] [-IfExist <Append | Skip | OverwriteLatest>] [-TargetLanguage <String[]>] [-DoNotCopyFields] [-IgnoredFields <String[]>] [-Language <String[]>]

Detailed Description

Creates a new version of the item in a specified language based on an existing language/version. Based on parameters you can make the command bahave differently when a version in the target language already exists and define which fields if any should be copied over from the original language.

© 2010-2020 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Aliases

The following abbreviations are aliases for this cmdlet:

  • Add-ItemLanguage

Parameters

-Recurse <SwitchParameter>

Process the item and all of its children.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-IfExist <ActionIfExists>

Default value is Append. Accepts one of 3 values:

  • Append - [Default] if language version exists create a new version with values copied from the original language

  • Skip - if language version exists don't do anything

  • OverwriteLatest - if language version exists overwrite the last version with values copied from the original language

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-IfNoSourceVersion <ActionIfNoVersion>

Default value is Skip. Accepts one of 2 values:

  • Skip - [Default] if the source item has no versions don't do anything

  • Add - if the source item has no versions create a version without any copied values

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-TargetLanguage <String[]>

Language or a list of languages that should be created

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DoNotCopyFields <SwitchParameter>

Creates a new version in the target language but does not copy field values from the original language

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-IgnoredFields <String[]>

List of fields that should not be copied over from original item. As an example, use "__Security" if you don't want the new version to have the same restrictions as the original version.

In addition to the fields in -IgnoredFields the following fields are ignored as configured in Spe.config file in the following location: configuration/sitecore/powershell/translation/ignoredFields.

Fields ignored out of the box include:

  • __Archive date

  • __Archive Version date

  • __Lock

  • __Owner

  • __Page Level Test Set Definition

  • __Reminder date

  • __Reminder recipients

  • __Reminder text

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Language <String[]>

Language that will be used as source language. If not specified the current user language will be used.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Item <Item>

The item / version to be processed.

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-Path <String>

Path to the item to be processed - additionally specify Language parameter to fetch different item language than the current user language.

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Id <String>

Id of the item to be processed - additionally specify Language parameter to fetch different item language than the current user language.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Database <String>

Database containing the item to be processed - can work with Language parameter to narrow the publication scope.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Sitecore.Data.Items.Item

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

Translate the Home Item from English to US and Polish leaving the "Title" field blank. If a version exists don't do anything

PS master:\> Add-ItemVersion -Path "master:\content\home" -Language "en" -TargetLanguage "pl-pl", "en-us" -IfExist Skip -IgnoredFields "Title"

EXAMPLE 2

Add a Japanese version to /sitecore/content/home item in the master database based on itself
PS master:\> Add-ItemVersion -Path "master:\content\home" -Language ja-JP -IfExist Append

EXAMPLE 3

Translate the children of Home item (but only those of Template Name "Sample Item") from English to US and Polish. If a version exists create a new version for that language. Display results in a table listing item name, language and created version number.

Get-ChildItem "master:\content\home" -Language "en" -Recurse | `
    Where-Object { $_.TemplateName -eq "Sample Item" } | `
    Add-ItemVersion -TargetLanguage "pl-pl" -IfExist Append | `
    Format-Table Name, Language, Version -auto

Related Topics

  • New-Item

ConvertFrom-ItemClone

Converts an item from a clone to a fully independent item.

Syntax

ConvertFrom-ItemClone [-Item] <Item> [-Recurse] [-PassThru]

ConvertFrom-ItemClone [-Path] <String> [-Recurse] [-PassThru]

ConvertFrom-ItemClone -Id <String> [-Database <String>] [-Recurse] [-PassThru]

Detailed Description

Converts an item from a clone to a fully independent item.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Recurse <SwitchParameter>

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-PassThru <SwitchParameter>

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Item <Item>

The item to be converted.

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-Path <String>

Path to the item to be converted

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Id <String>

Id of the item to be converted

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Database <String>

Database containing the item to be converted

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Sitecore.Data.Items.Item

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE

PS master:\> ConvertFrom-ItemClone -Path master:\content\home

Related Topics

Close-Window

Closes the runner job window after the script completes.

Syntax

Close-Window

Detailed Description

Ensures the runner process window is closed after the script finishes execution. This is commonly used when the runner should close after a report runs while in the Desktop mode.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE

PS master:\> Close-Window

Related Topics

Authoring Reports

Building reports is a straightforward task. We've provided a variety of examples for you to model when designing your own.

Dynamic Reports

The Authorable Reports module includes reports such as Index Viewer and Rules based report that provide input dialogs to help make the reports dynamic.

Note: The Index Viewer and Rules Based Report are bundled as separate a package on the Sitecore Marketplace.

Index Viewer

The Index Viewer report provides a great example at how to build a generic report that queries against the Sitecore index. By navigating to Sitecore -> Toolbox -> Index Viewer you can conveniently launch the report.

First you will be prompted with a dialog to select the index to search.

Next you will be prompted with a variety of buttons and knobs to narrow down the search results.

Finally the report is shown. Each row has an option to show more field results.

The Show Full Info link will then returns the additional fields not shown in the report.

The Authorable Reports module has a few points of interest.

  • The script library Internal/List View/Ribbon/SearchResultItem instructs the report to show the action scripts when the row contains an entry with the typename SearchResultItem.

  • The script library Toolbox/Index Viewer represents the shortcut.

Examples:

Static Reports

The Content Reports module includes other reports used for auditing. Below are some examples on how to create your own. You can control the report menu with the Enable and Show rules. This can be helpful if you want to secure specific reports with security roles.

The rules engine can be used the control the report export and action commands. Use the Enable and Show rules to make the necessary changes.

Examples:

Report Actions

Actions are simply commands powered by scripts and with visibility dependent on certain conditions like the .Net class of the object that is displayed or perhaps other session settings.

You define an action as a script located in an SPE script library and appears in the Actions panel. In the simplest scenario the action would appear when the script library name matches the .Net class name of the items displayed. In the above scenario the actions are placed under /Platform/Internal/List View/Ribbon/Item/ where Platform is the module and Item is a script library. Let's take a look at the script here /Platform/Internal/List View/Ribbon/Item/Open

foreach($item in $selectedData){
# Run Sheer application on Desktop
Show-Application `
    -Application "Content Editor" `
    -Parameter @{id ="$($item.ID)"; fo="$($item.ID)"; 
                 la="$($item.Language.Name)"; vs="$($item.Version.Number)";
                 sc_content="$($item.Database.Name)"}
}

The variable $selectedData is provided to the script automatically by SPE in context of the content of the results on Show-ListView.

What input is passed to an action script?

When your action script is executed the environment is initialized with a number of variables at your disposal as seen below:

  • $selectedData – the selected objects in the list view (the same will be passed to the $resultSet variable for compatibility with older scripts)

  • $allData – all objects passed to the list view using the -Data parameter.

  • $filteredData – all objects displayed after filtering is performed with the search criteria entered by the user in the ribbon.

  • $exportData – same as $filteredData, however in this case the objects will have additional properties to support easy display with properties processed as text.

  • $actionData – any object that was passed to Show-ListView using the -ActionData parameter. Useful when you need additional context that the Show-ListView command does not explicitly know about. It’s your custom data.

  • $formatProperty – the content of the –Property parameter when running the command.

  • $title – window title of the list view.

  • $infoTitle – info title of the list view.

  • $infoDescription – info title of the list view.

Consequently you get the full state of the report the user sees in the UI and you can act upon it.

How the report determines if your action is visible?

You can have multiple actions defined with dynamic visibility. The actions are generally only relevant in the context of your report. This is done on two levels. The first level happens based on the location of the script and .Net object type you are displaying in the report. The second level is based on Sitecore rules. For the action to appear all of the following conditions must be met:

  • All scripts visible in the report should be located in an enabled module.

  • The action script should be within the path /Internal/List View/Ribbon/[Object type]. The [Object type] is the name of the .Net class for which the action is valid. For example, if you want your action to be visible for Sitecore.Data.Items.Item then save the script at the path /Internal/List View/Ribbon/Item.

  • If the action script has no rules defined in the "Show if rules are met or not defined" field it will appear for all objects passed to Show-ListView that are of the type based on location. Rules will provide more granular control and allow for rule-based conditions that determine action visibility.

Using rules to control action visibility

The following screenshot shows how to create an action that only appears in reports that list objects of type Item that are of template Schedule.

For specific reports this global state might not always be enough. You can narrow down the rules further by using the report name. Name your report by providing an additional parameter to Show-ListView.

Consider the following script:

Get-ChildItem master:\ | Show-ListView -ViewName ListChildren

The output of the report will be like any other unnamed report but adds support for additional rules. Let's say I want my action to open a new report that lists all the children of the selected items in the report "ListChildren". After running the action my script should display the new report with the children and close the "ListChildren" report. Not very useful but illustrates the point.

Now I need to save my script in the proper Script Library in my enabled module:

At this point my action will show on all reports what list Item objects. But now that my script is saved I can modify its rules to narrow it down only to Show for reports named "ListChildren". For this I can click the Runtime button in the ISE ribbon and edit the Show if rules are met or not defined field.

Now you can specify that you want the action to only appear when the report is named "ListChildren".

Confirm the save on all dialogs to persist your changes. Now our action appears when we run this script in ISE.

Get-ChildItem master:\ | Show-ListView -ViewName ListChildren -Property Name, ProviderPath

The action does not appear if no view name is provided to the -ViewName parameter. Running the script below will produce a report with the action not shown:

Get-ChildItem master:\ | Show-ListView -Property Name, ProviderPath

Updating report in place

The above action works just fine but will close the previous report and open a new report window in the Sitecore desktop. That's not a great user experience. What if you want to update the content of the report in place using the action? That's possible using the Update-ListView command. Consider the following script:

In this case we're not closing the existing report but rather updating the list in place, all you need to do is send the new data to the Update-ListView command.

Showing user progress for long running scripts

One last thing that you might wonder is if the Write-Progress command works as it does in case of ISE or the dialog that runs scripts from Content Editor context menu. Let’s copy the following script into your action:

for($i = 0; $i -le 10; $i++){
  Write-Progress -Activity "I need to do something important for 5 seconds" `
    -Status "I'm quite on track..." `
    -PercentComplete ($i*10) -SecondsRemaining (5-$i/2) `
    -CurrentOperation "Trying to look busy.";
  Start-Sleep -m 500
}

Write-Progress -Activity "Now I'm doing something else..." `
    -Status "Should take me about 3 seconds but I'm not quite sure...";
Start-Sleep -s 3;

for($i = 0; $i -le 10; $i++){
  Write-Progress -Activity "Ok let me revisit one more thing..." `
    -Status "Just 5 more seconds" `
    -PercentComplete ($i*10) -SecondsRemaining (5-$i/2) `
    -CurrentOperation "Just making sure.";
  Start-Sleep -m 500;
}

Write-Progress -Completed -Activity "Done."

And you will see the following output:

Showing other PowerShell dialogs

The action runs fully asynchronously so you’re free to show any of the power of the provided commands. This means that you can ask for additional input using the Read-Variable command or Show alert using the Show-Alert command or do just about anything possible otherwise from the context menu, ribbon or other interactive integration points.

Passing additional data to actions

The Show-ListView command has one more useful parameter named -ActionData which I mentioned above but is worth mentioning again. Anything passed using this parameter will be set as the $actionData variable – this means your report and actions can pass custom data in them it can be as simple as an object or as complex as a hashtable so there is really no hard limit on what can progress from a report to report. Any object that was passed to Show-ListView using the -ActionData parameter will be available to your action.

Actions running in persistent sessions

The persistent session ID will be respected and your script will run in that persistent session if it's already in memory or create a persistent session if it's not.

Alternatively you can elect to simply freeze the session the initial script that generated report was running in and run actions in that same frozen session by using the -ActionsInSession parameter.

UI Elements

The Show-ListView command provides the Hide parameter to control visibility of the UI elements.

Add parameter -Hide with one or more of the following options:

  • AllExport - hides all export scripts (left-most ribbon panel)

  • NonSpecificExport - hides export filters that are not specific to this view as specified by -ViewName (left-most ribbon panel)

  • Filter - hides filter panel

  • PagingWhenNotNeeded - hides paging when list is shorter than the page specified

  • AllActions - hides all actions (right-most ribbon panel)

  • NonSpecificActions - hides actions that are not specific to this view as specified by -ViewName (right-most ribbon panel)

  • StatusBar - hides status bar.

Example: The following example all of the UI elements in the report.

Get-ChildItem master:\ | 
    Show-ListView `
        -Hide AllActions, AllExport, Filter, PagingWhenNotNeeded, StatusBar `
        -Property Name, DisplayName, ProviderPath, __Updated, "__Updated By"

Examples from the community!

ConvertFrom-CliXml

Imports a CliXml string with data that represents Microsoft .NET objects and creates the objects within PowerShell.

Syntax

ConvertFrom-CliXml [-InputObject] <String>

Detailed Description

The ConvertFrom-CliXml command imports a CliXml string with data that represents Microsoft .NET Framework objects and creates the objects in PowerShell.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-InputObject <String>

String containing the Xml with serialized objects.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • System.String

Outputs

The output type is the type of the objects that the cmdlet emits.

  • object

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE

Related Topics

  • ConvertTo-Xml

  • ConvertFrom-Xml

  • Export-CliXml

  • Import-CliXml

Appendix

Compatibility Table

Legend: "–" - not supported; "✓" - supported.

Compatibility Notes

  • [2] Some features are not available. It is recommended to upgrade to the latest version available for 9.2.

Releases

When reviewing the different download packages you may see some names that are not too clear. The following list outlines what those names should mean.

  • N.X : Full N.X release - This refers to the package used by Standalone and CM roles. This includes what is required to see the PowerShell ISE, Console and their associated services.

  • N.X Minimal : Server-side remoting only - This refers to the package with only files. Useful for remotely connecting to SPE.

  • N.X Authorable Reports : Additional reports and tools - This package is a sublemental installation to the full version with additional reports. With version 6.0 this package is no longer needed as the reports are included with the full release.

  • N.X Remoting : SPE Remoting module for CI/CD - This provides a Windows PowerShell module for connecting to SPE remotely. Use in combination with the full or minimal packages.

Manage Templates

Examples for managing item templates.

Manage Templates

Change Template

Sitecore Stack Exchange

The following examples are best kept on SSE since it provides more context about the problem being solved.

Get-Database

Retrieves a Sitecore Database.

Syntax

Get-Database [[-Name] <String>] [-Item <Item>]

Detailed Description

The Get-Database command retrieves one or more Sitecore Database objects based on name or item passed to it.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Name <String>

Name of the database to be returned.

-Item <Item>

Database returned will be taken from the item passed to the command.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

    System.String

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Sitecore.Data.Database

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

EXAMPLE 2

EXAMPLE 3

Related Topics

Get-Cache

Retrieves a Sitecore cache.

Syntax

Get-Cache [[-Name] <String>]

Detailed Description

The Get-Cache command retrieves a Sitecore cache.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Name <String>

Name of the cache to retrieve. Supports wildcards.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Sitecore.Caching.Cache

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE

Related Topics

Pipelines

Use the following in your scripts to get access to the arguments passed to the processor.

Configure any Enable rules to ensure your script only runs when necessary.

Logging In

Note: Examples included in the following modules

  • Enforce user password expiration

Logged In

Note: Examples included in the following modules

  • Automatically show quick info section

Logout

Note: Examples included in the following modules

  • Unlock user items on logout

Example: The following changes the image linked on an item to a new image. Originally posted .

Example: The following removes an item link followed by removing the item. Originally posted .

Content extracted from article written by Adam.

Rules add the full power of the Sitecore rules engine – similarly to what you can do on context menu items or ribbon actions in Content Editor. Some examples where this can be useful include only enabling or disabling the action for items located under a specific branch of the tree or if a exists.

Report with all UI elements hidden

for Sitecore product has published reports on Github that you can checkout .

Aliases

[1] Released by Sitecore for SXA which can be download from the however you should be safe simply installing the official SPE release on GitHub.

Publish-Item command unsupported ()

Indexing commands unsupported ()

Find all items based on a template found anywhere in the inheritance chain.

Aliases
Aliases

Aliases

here
here
https://github.com/SitecorePowerShell/Console/
Remove-ItemVersion
https://gist.github.com/AdamNaj/b36ea095e3668c22c07e
New-ItemClone
Get-ItemClone
https://github.com/SitecorePowerShell/Console/
https://github.com/SitecorePowerShell/Console/
Creating Beautiful Sitecore Reports Easily with PowerShell Extensions
Images with an empty alt field
Unused media items
Turn Your Sitecore Powershell Reports into Applications with Action Scripts
persistent session
Active Commerce
here

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

PS master:\> #Convert original item to xml
PS master:\> $myCliXmlItem = Get-Item -Path master:\content\home | ConvertTo-CliXml 
PS master:\> #print the CliXml
PS master:\> $myCliXmlItem
PS master:\> #print the Item converted back from CliXml
PS master:\> $myCliXmlItem | ConvertFrom-CliXml
# Sample Item
$sourceTemplate = Get-Item -Path "master:\{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}"
# Sample Content
$targetTemplate = Get-Item -Path "master:\{93A8866B-972F-4FBF-8FD9-D6004B18C0AF}"

# Use Get-ItemReferrer to find all items referencing the template, rather than scanning the content tree.
$sourceTemplate | Get-ItemReferrer | 
    Where-Object { $PSItem.TemplateId -eq $sourceTemplate.ID -and $PSItem.Paths.IsContentItem } |
    ForEach-Object {
        Set-ItemTemplate -Item $PSItem -TemplateItem $targetTemplate
    }

Required?

false

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

PS master:\> Get-Database
Name                 Languages                      Protected  Read Only
----                 ---------                      ---------  ---------
core                 {da, pl-PL, ja-JP, en...}      False      False
master               {en, de-DE, es-ES, pt-BR...}   False      False
web                  {es-ES, de-DE, pt-BR, pl-PL... False      False
filesystem           {en, en-US}                    False      True
PS master:\> Get-Database -Name "master"

Name                 Languages                      Protected  Read Only
----                 ---------                      ---------  ---------
master               {en, de-DE, es-ES, pt-BR...}   False      False
PS master:\> Get-Item . | Get-Database

Name                 Languages                      Protected  Read Only
----                 ---------                      ---------  ---------
master               {en, de-DE, es-ES, pt-BR...}   False      False

Required?

false

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

PS master:\> Get-Cache -Name master*

Name                                     Enabled       Count       Size   Max Size Default  Scavengable
                                                                                   Priority
----                                     -------       -----       ----   -------- -------- -----------
master[blobIDs]                          True              0          0     512000   Normal       False
master[blobIDs]                          True              0          0     512000   Normal       False
master[blobIDs]                          True              0          0     512000   Normal       False
master[itempaths]                        True            292     108228   10485760   Normal       False
master[standardValues]                   True             57      38610     512000   Normal       False
master[paths]                            True            108      13608     512000   Normal       False
master[items]                            True           1010    5080300   10485760   Normal       False
master[data]                             True           3427    7420654   20971520   Normal       False
 $pipelineArgs = Get-Variable -Name pipelineArgs -ValueOnly
$pipelineArgs.Username
$pipelineArgs.Password
$pipelineArgs.Success
$pipelineArgs.StartUrl
$pipelineArgs.Username
$pipelineArgs.StartUrl
https://github.com/SitecorePowerShell/Console/
ConvertTo-CliXml
https://github.com/SitecorePowerShell/Console/issues/218
Downloads are hosted on Github
SXA 1.9.0 release page
#1129
#1133
Question
https://github.com/SitecorePowerShell/Console/
https://github.com/SitecorePowerShell/Console/

SPE ↓ / Sitecore→

8.0

8.1

8.2

9.0

9.1

9.2

9.3

10.0

10.1

10.2

10.3

10.4

4.0

✓

✓

–

–

–

–

–

-

-

-

-

-

4.1-4.6

✓

✓

✓

–

–

–

–

-

-

-

-

-

4.7

✓

✓

✓

✓

✓

–

–

-

-

-

-

-

5.0

✓

✓

✓

✓

✓

–

-

-

-

-

-

5.1

✓

✓

✓

✓

✓

–

-

-

-

-

-

6.0-6.2

✓

✓

✓

✓

✓

✓

✓

✓

✓

-

-

-

6.3

✓

✓

✓

✓

✓

✓

✓

✓

✓

✓

-

-

6.4

✓

✓

✓

✓

✓

✓

✓

✓

✓

✓

✓

-

7.0

✓

✓

✓

✓

✓

✓

✓

✓

✓

✓

✓

✓

Expand-Token

Expands tokens in fields for items.

Syntax

Expand-Token [-Item] <Item> [-Language <String[]>]

Expand-Token [-Path] <String> [-Language <String[]>]

Expand-Token -Id <String> [-Database <String>] [-Language <String[]>]

Detailed Description

The Expand-Token command expands the tokens in fields for items.

Some example of tokens include:

  • $name

  • $time

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Language <String[]>

Language that will be processed. If not specified the current user language will be used. Globbing/wildcard supported.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Item <Item>

The item to be processed.

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-Path <String>

Path to the item to be processed - additionally specify Language parameter to fetch different item language than the current user language.

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Id <String>

Id of the the item to be processed - additionally specify Language parameter to fetch different item language than the current user language.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Database <String>

Database containing the item to be processed - can work with Language parameter to narrow the publication scope.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Sitecore.Data.Items.Item

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

The following expands tokens in fields on the item.

Get-Item -Path "master:\content\home" | Expand-Token

EXAMPLE 2

The following expands tokens in fields on the item. If the standard value of the field contains a token we modify the field to the token so the expansion will work (Sitecore API does not expand if the field is the same as Standard Values and never modified).

$tokens = @('$name', '$id', '$parentId', '$parentname', '$date', '$time', '$now')

$item = Get-Item -Path "master:\content\home"

$standardValueFields = Get-ItemField -Item $item -ReturnType Field -Name "*" `
    | Where-Object { $_.ContainsStandardValue }
    
$item.Editing.BeginEdit()

foreach ($field in $standardValueFields) {
    $value = $field.Value
    
    if ($tokens -contains $value) {
        $item[$field.Name] = $value
    }
}

$item.Editing.EndEdit()

Expand-Token -Item $item

Related Topics

Get-Archive

Returns Sitecore database archives.

Syntax

Get-Archive [[-Database] <Database>] [[-Name] <String>]

Detailed Description

The Get-Archive command returns Sitecore archives in context of the specified database.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Name <String>

Name of the archive to retrieve.

Aliases

Required?

false

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Database <Database>

Database for which the archives should be retrieved.

Aliases

Required?

false

Position?

2

Default Value

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Database

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Sitecore.Data.Archiving.Archive

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE

PS master:\> Get-Archive -Database "master"

Name                                        Items
----                                        -----
archive                                         0
recyclebin                                   1950

Related Topics

ConvertTo-CliXml

Exports Microsoft .NET objects froms PowerShell to a CliXml string.

Syntax

ConvertTo-CliXml [-InputObject] <PSObject>

Detailed Description

The ConvertTo-CliXml command exports Microsoft .NET Framework objects from PowerShell to a CliXml string.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-InputObject <PSObject>

Specifies the object to be converted. Enter a variable that contains the objects, or type a command or expression that gets the objects. You can also pipe objects to ConvertTo-CliXml.

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • object

Outputs

The output type is the type of the objects that the cmdlet emits.

  • System.String

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE

PS master:\> #Convert original item to xml
PS master:\> $myCliXmlItem = Get-Item -Path master:\content\home | ConvertTo-CliXml 
PS master:\> #print the CliXml
PS master:\> $myCliXmlItem
PS master:\> #print the Item converted back from CliXml
PS master:\> $myCliXmlItem | ConvertFrom-CliXml

Related Topics

  • ConvertFrom-Xml

  • ConvertTo-Xml

  • Export-CliXml

  • Import-CliXml

Get-ItemReference

Returns all the items linked to the specified item..

Syntax

Get-ItemReference -Item <Item>

Get-ItemReference -Item <Item> -ItemLink

Get-ItemReference -Path <String> [-Language <String[]>]

Get-ItemReference -Path <String> [-Language <String[]>] -ItemLink

Get-ItemReference -Id <String> [-Database <String>] [-Language <String[]>]

Get-ItemReference -Id <String> [-Database <String>] [-Language <String[]>] -ItemLink

Detailed Description

The Get-ItemReference command returns all items linked to the specified item. If -ItemLink parameter is used the command will return links rather than items.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Item <Item>

The item to be analysed.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-Path <String>

Path to the item to be processed - additionally specify Language parameter to fetch different item language than the current user language.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Id <String>

Id of the the item to be processed - additionally specify Language parameter to fetch different item language than the current user language.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Database <String>

Database containing the item to be processed - can work with Language parameter to narrow the publication scope.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Language <String[]>

Language that will be used as source language. If not specified the current user language will be used. Globbing/wildcard supported.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ItemLink <SwitchParameter>

Return ItemLink that define both source and target of a link rather than items that are being linked to from the specified item.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Sitecore.Data.Items.Item

    Sitecore.Links.ItemLink

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

PS master:\>Get-ItemReference -Path master:\content\home

Name                             Children Languages                Id                                     TemplateName
----                             -------- ---------                --                                     ------------
Home                             True     {en, de-DE, es-ES, pt... {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} Sample Item
Home                             True     {en, de-DE, es-ES, pt... {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} Sample Item

EXAMPLE 2

PS master:\>Get-Item master:\content\home | Get-ItemReference -ItemLink

SourceItemLanguage : en
SourceItemVersion  : 1
TargetItemLanguage :
TargetItemVersion  : 0
SourceDatabaseName : master
SourceFieldID      : {F685964D-02E1-4DB6-A0A2-BFA59F5F9806}
SourceItemID       : {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}
TargetDatabaseName : master
TargetItemID       : {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}
TargetPath         : /sitecore/content/Home

Related Topics

Get-ItemReferrer

Returns all the items referring to the specified item.

Syntax

Get-ItemReferrer -Item <Item>

Get-ItemReferrer -Item <Item> -ItemLink

Get-ItemReferrer -Path <String> [-Language <String[]>]

Get-ItemReferrer -Path <String> [-Language <String[]>] -ItemLink

Get-ItemReferrer -Id <String> [-Database <String>] [-Language <String[]>]

Get-ItemReferrer -Id <String> [-Database <String>] [-Language <String[]>] -ItemLink

Detailed Description

The Get-ItemReferrer command returns all items referring to the specified item. If -ItemLink parameter is used the command will return links rather than items.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Item <Item>

The item to be analysed.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-Path <String>

Path to the item to be processed - additionally specify Language parameter to fetch different item language than the current user language.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Id <String>

Id of the the item to be processed - additionally specify Language parameter to fetch different item language than the current user language.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Database <String>

Database containing the item to be processed - can work with Language parameter to narrow the publication scope.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Language <String[]>

Language that will be used as source language. If not specified the current user language will be used. Globbing/wildcard supported.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ItemLink <SwitchParameter>

Return ItemLink that define both source and target of a link rather than items linking to the specified item.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Sitecore.Data.Items.Item

    Sitecore.Links.ItemLink

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

PS master:\>Get-ItemReferrer -Path master:\content\home

Name                             Children Languages                Id                                     TemplateName
----                             -------- ---------                --                                     ------------
Home                             True     {en, de-DE, es-ES, pt... {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} Sample Item
Form                             False    {en, de-DE, es-ES, pt... {6D3B4E7D-FEF8-4110-804A-B56605688830} Webcontrol
news                             True     {en, de-DE, es-ES, pt... {DB894F2F-D53F-4A2D-B58F-957BFAC2C848} Article
learn-about-oms                  False    {en, de-DE, es-ES, pt... {79ECF4DF-9DB7-430F-9BFF-D164978C2333} Link

EXAMPLE 2

PS master:\>Get-Item master:\content\home | Get-ItemReferrer -ItemLink

SourceItemLanguage : en
SourceItemVersion  : 1
TargetItemLanguage :
TargetItemVersion  : 0
SourceDatabaseName : master
SourceFieldID      : {F685964D-02E1-4DB6-A0A2-BFA59F5F9806}
SourceItemID       : {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}
TargetDatabaseName : master
TargetItemID       : {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}
TargetPath         : /sitecore/content/Home

Related Topics

Web API

The Web API integration point exposes scripts through a url. This can be especially helpful when a script needs to be executed on the server but without knowledge of the script contents.

Here's the url broken down:

  • API Version - Specifies which service is being requested.

    • v2 - This is the service that executes scripts stored in the integration point library.

  • Database - Specifies which database contains the script.

    • master - This database requires the credentials to be provided.

  • Script - Specifies the name of the script contained in the database. The SPE module containing the script needs to be enabled otherwise you'll receive a 404 error.

    • homeanddescendants - Replace this name with whatever your script is called in the Web API library.

  • Query String Parameters (deprecated) - Specifies the additional bits of data for use by the web service.

    • user and password - Authenticates the request and in most cases will be needed. If the script is published to the web database the credentials are not required. You should use the Basic header instead of the query string.

    • All of the query string parameters added to the variable scriptArguments. Use this PowerShell hashtable inside of your scripts. Check out the function Invoke-ApiScript for an example of how these parameters can be put to good use.

Headers:

Use the Basic header to provide authentication information. Here is an example of how to build that for a script.

$username = "admin"
$password = "b"

$pair = "$($username):$($password)"

$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))

$basicAuthValue = "Basic $encodedCreds"

$headers = @{
    Authorization = $basicAuthValue
}

Invoke-RestMethod -Headers $headers -Uri "https://spe.dev.local/-/script/v2/master/TrainingWebApi?offset=3&limit=2&fields=(Name,ItemPath,Id)"

Note: Examples included in the following modules

  • Getting Started

Security

References

Releases

The following links provide a way to report issues and get the latest release.

Get-ItemWorkflowEvent

Returns entries from the history store notifying of workflow state change for the specified item.

Syntax

Get-ItemWorkflowEvent [-Item] <Item> [-Identity <String>] [-Language <String[]>]

Get-ItemWorkflowEvent [-Path] <String> [-Identity <String>] [-Language <String[]>]

Get-ItemWorkflowEvent -Id <String> [-Database <String>] [-Identity <String>] [-Language <String[]>]

Detailed Description

The Get-ItemWorkflowEvent command returns entries from the history store notifying of workflow state change for the specified item.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Identity <String>

User that has been associated with the enteries. Wildcards are supported.

-Language <String[]>

Language that will be used as source language. If not specified the current user language will be used. Globbing/wildcard supported.

-Item <Item>

The item to have its history items returned.

-Path <String>

Path to the item to have its history items returned - additionally specify Language parameter to fetch different item language than the current user language.

-Id <String>

Id of the the item to have its history items returned - additionally specify Language parameter to fetch different item language than the current user language.

-Database <String>

Database containing the item to have its history items returned - can work with Language parameter to narrow the publication scope.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Sitecore.Workflows.WorkflowEvent

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE

Related Topics

  • Execute-Workflow

Get-ItemClone

Returns all the clones for the specified item.

Syntax

Get-ItemClone [-Item] <Item>

Get-ItemClone [-Path] <String>

Get-ItemClone -Id <String> [-Database <String>]

Detailed Description

The Get-ItemClone command returns all the clones for the specified item.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Item <Item>

The item to be analysed for clones presence.

-Path <String>

Path to the item to be analysed for clones presence.

-Id <String>

Id of the item to be analysed for clones presence.

-Database <String>

Database containing the item to be processed - if item is being provided through Id.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Sitecore.Data.Items.Item

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE

Related Topics

  • Get-Item

Code Snippets

Useful code snippets to help you with those complex scripts.

List fields on template

Example: The following demonstrates how to list all of the fields of a template excluding the Standard Template fields.

Media item url

Example: The following demonstrates how to generate the public facing url from a media item.

Parse Html

Example: The following demonstrates the use of the HtmlAgilityPack for parsing html.

Example: The following demonstrates how to update text in the document and exclude certain nodes.

Example: The following demonstrates how to remove empty paragraph tags in an html field.

Example: The following demonstrates removing style attributes from the html.

Workflow History

Example: The following prints the workflow history of the home item.

Restore Recycle bin items

Purge Recycle bin items

Example: The following will incrementally purge items from the recycle bin (master db) with a progress counter.

Run JavaScript

Example: The following logs messages to the browser console and then alerts the user with a message.

Remoting

✓

✓

The url will look something like the following:

The integration point is disabled by default and can be enabled through configuration as described . See Restfulv2. Be sure to enable the SPE script module in the content tree.

Watch Adam present this and much more on Sitecore! Experienced .

Thank you for taking the time to check out the latest and greatest changes for SPE. Send a tweet sharing how much you love the module on .

See the for a compatibility matrix.

Aliases
Aliases
Aliases
Aliases
Aliases
Aliases

Aliases
Aliases
Aliases
Aliases

Example: The following restores items in the media library that were removed yesterday. @technomaz.

Example:

Not seeing what you are looking for? You can always check out some Github Gists that and have shared or the .

https://github.com/SitecorePowerShell/Console/
https://sitecorejunkie.com/2014/05/27/launch-powershell-scripts-in-the-item-context-menu-using-sitecore-powershell-extensions/
https://sitecorejunkie.com/2014/06/02/make-bulk-item-updates-using-sitecore-powershell-extensions/
https://github.com/SitecorePowerShell/Console/
https://github.com/SitecorePowerShell/Console/
ConvertFrom-CliXml
Get-ItemReferrer
Update-ItemReferrer
https://github.com/SitecorePowerShell/Console/
Get-ItemReference
Update-ItemReferrer
https://github.com/SitecorePowerShell/Console/
https://remotesitecore/-/script/v2/master/homeanddescendants?user=sitecore\admin&password=b
here
here
[1]
[2]
[2]

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

PS master:\> Get-ItemWorkflowEvent -Path master:\content\home
Date     : 2014-07-27 14:23:33
NewState : {190B1C84-F1BE-47ED-AA41-F42193D9C8FC}
OldState : {46DA5376-10DC-4B66-B464-AFDAA29DE84F}
Text     : Automated
User     : sitecore\admin

Date     : 2014-08-01 15:43:29
NewState : {190B1C84-F1BE-47ED-AA41-F42193D9C8FC}
OldState : {190B1C84-F1BE-47ED-AA41-F42193D9C8FC}
Text     : Just leaving a note
User     : sitecore\admin

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

PS master:\> Get-ItemClone -Path master:\content\home
# 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-4858AC7CF696}"
$standardTemplateTemplateItem = [Sitecore.Data.Items.TemplateItem]$standardTemplate
$standardFields = $standardTemplateTemplateItem.OwnFields + $standardTemplateTemplateItem.Fields | Select-Object -ExpandProperty key -Unique

$itemTemplate = Get-Item -Path "master:" -ID "{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}"
$itemTemplateTemplateItem = [Sitecore.Data.Items.TemplateItem]$itemTemplate
$itemTemplateFields = $itemTemplateTemplateItem.OwnFields + $itemTemplateTemplateItem.Fields | Select-Object -ExpandProperty key -Unique

$filterFields = $itemTemplateFields | Where-Object { $standardFields -notcontains $_ } | Sort-Object
$item = Get-Item -Path "master:{04DAD0FD-DB66-4070-881F-17264CA257E1}"
$siteName = "website"

$site = [Sitecore.Sites.SiteContextFactory]::GetSiteContext($siteName)
New-UsingBlock (New-Object Sitecore.Sites.SiteContextSwitcher $site) {
    [Sitecore.Resources.Media.MediaManager]::GetMediaUrl($item)
}

# /-/media/default-website/cover.jpg
$html = "<ul><li>foo</li><li>bar</li></ul>"
$htmlDocument = New-Object -TypeName HtmlAgilityPack.HtmlDocument
$htmlDocument.LoadHtml($html)
foreach($x in $htmlDocument.DocumentNode.SelectNodes("//li")) {
    $x.InnerText;
}
$html = @"
<div class="kitchen">
   <div class="kitchen">
        <blockquote>kitchen<br />
            <span class="kitchen">kitchen</span>
        </blockquote>
        <a><img title="kitchen" src="https://kitchen-sink.local" /></a>
    </div>
</div>
"@

$htmlDocument = New-Object -TypeName HtmlAgilityPack.HtmlDocument
$htmlDocument.LoadHtml($html)
foreach($x in $htmlDocument.DocumentNode.Descendants()) {
    if($x.Name -ne "img" -and ![string]::IsNullOrEmpty($x.Text)) {
        $x.Text = $x.Text.Replace("kitchen", "sink")
    }
}

$htmlDocument.DocumentNode.OuterHtml
$html = @"
<div style='padding: 10px 10px;'>Some Text</div>
"@

$htmlDocument = New-Object -TypeName HtmlAgilityPack.HtmlDocument
$htmlDocument.LoadHtml($html)
$nodes = $htmlDocument.DocumentNode.SelectNodes("//@style");
foreach($node in $nodes) {
    $node.Attributes["style"].Remove()
}
$htmlDocument.DocumentNode.OuterHtml
$item = Get-Item -Path "master:" -Id "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}"

$db = Get-Database -Name "master"
$workflowProvider = $db.WorkflowProvider

foreach($version in $item.Versions.GetVersions()) {
    $workflowEvents = $workflowProvider.HistoryStore.GetHistory($version)
    foreach($workflowEvent in $workflowEvents) {
        "[$($workflowEvent.Date)] ($($workflowEvent.User)) $(($workflowEvent.Text -replace '(\r|\n)',''))"
    }
}
Write-Host "Restoring items recycled after $($archivedDate.ToShortDateString())"

foreach($archive in Get-Archive -Name "recyclebin") {
    Write-Host " - Found $($archive.GetEntryCount()) entries"
    $entries = $archive.GetEntries(0, $archive.GetEntryCount())
    foreach($entry in $entries) {
        if($entry.ArchiveLocalDate -ge $archivedDate) { 
            Write-Host "Restoring item: $($entry.OriginalLocation) {$($entry.ArchivalId)}on date $($entry.ArchiveLocalDate)"
            $archive.RestoreItem($entry.ArchivalId)
        } else {
            Write-Host "Skipping $($entry.OriginalLocation) on date $($entry.ArchiveLocalDate)"
        }
    }
}
$database = Get-Database -Name "master"
$archiveName = "recyclebin"
$archive = Get-Archive -Database $database -Name $archiveName
$items = Get-ArchiveItem -Archive $archive

$count = 0
$total = $items.Count
foreach($item in $items) {
    $count++
    if($count % 100 -eq 0) {
        Write-Host "[$(Get-Date -Format 'yyyy-MM-dd hh:mm:ss')] $([math]::round($count * 100 / $total, 2))% complete"
    }
    $item | Remove-ArchiveItem
}
Write-Host "Completed processing recycle bin"
1..5 | ForEach-Object { 
    Start-Sleep -Seconds 1
    Invoke-JavaScript -Script "console.log('Hello World! Call #$($_) from PowerShell...');" 
}

Invoke-JavaScript -Script "alert('hello from powershell');"
Import-Module -Name SPE -Force

$packageName = "$($SitecorePackageFolder)\[PACKAGE].zip"

$session = New-ScriptSession -Username "admin" -Password "b" -ConnectionUri "https://remotesitecore"
Test-RemoteConnection -Session $session -Quiet
$jobId = Invoke-RemoteScript -Session $session -ScriptBlock {
    [Sitecore.Configuration.Settings+Indexing]::Enabled = $false
    Get-SearchIndex | ForEach-Object { Stop-SearchIndex -Name $_.Name }
    Import-Package -Path "$($SitecorePackageFolder)\$($using:packageName)" -InstallMode Merge -MergeMode Merge
    [Sitecore.Configuration.Settings+Indexing]::Enabled = $true
} -AsJob
Wait-RemoteScriptSession -Session $session -Id $jobId -Delay 5 -Verbose
Stop-ScriptSession -Session $session

Get-ItemCloneNotification

Syntax

Get-ItemCloneNotification [-Item] <Item> [-NotificationType <Notification | ChildCreatedNotification | FieldChangedNotification | FirstVersionAddedNotification | ItemMovedChildCreatedNotification | ItemMovedChildRemovedNotification | ItemMovedNotification | ItemTreeMovedNotification | ItemVersionNotification | OriginalItemChangedTemplateNotification | VersionAddedNotification>] [-Language <String[]>]
Get-ItemCloneNotification [-Path] <String> [-NotificationType <Notification | ChildCreatedNotification | FieldChangedNotification | FirstVersionAddedNotification | ItemMovedChildCreatedNotification | ItemMovedChildRemovedNotification | ItemMovedNotification | ItemTreeMovedNotification | ItemVersionNotification | OriginalItemChangedTemplateNotification | VersionAddedNotification>] [-Language <String[]>]
Get-ItemCloneNotification -Id <String> [-Database <String>] [-NotificationType <Notification | ChildCreatedNotification | FieldChangedNotification | FirstVersionAddedNotification | ItemMovedChildCreatedNotification | ItemMovedChildRemovedNotification | ItemMovedNotification | ItemTreeMovedNotification | ItemVersionNotification | OriginalItemChangedTemplateNotification | VersionAddedNotification>] [-Language <String[]>]

Detailed Description

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-NotificationType <NotificationType>

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Language <String[]>

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Item <Item>

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-Path <String>

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Id <String>

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Database <String>

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Examples

EXAMPLE 1

The following gets the cloned Item and returns the available notifications.

$clonedItem = Get-Item -Path "master:" -ID "{9F158637-52C2-4005-8329-21527685CB71}"
Get-ItemCloneNotification -Item $clonedItem

EXAMPLE 2

The following gets the cloned Item based on the specified type of notification.

$clonedItem = Get-Item -Path "master:" -ID "{9F158637-52C2-4005-8329-21527685CB71}"
$clonedItem | Get-ItemCloneNotification -NotificationType ItemMovedChildRemovedNotification
Twitter
Book issue tracker
Module issue tracker
Module releases
Appendix
New-ItemWorkflowEvent
https://github.com/SitecorePowerShell/Console/
New-ItemClone
ConvertFrom-ItemClone
https://github.com/SitecorePowerShell/Console/
https://github.com/SitecorePowerShell/Console/issues/218
Sitecore Stack Exchanage
Credit
Remote Package Installation
Adam
Michael
Sitecore Stack Exchange

Get-UserAgent

Returns the current user's browser user agent.

Syntax

Detailed Description

Returns current user's browser user agent. Works only if Console is running outside of job. (e.g. in ISE - script needs to be run from the dropdown under the "Execute" button)

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

Outputs

The output type is the type of the objects that the cmdlet emits.

  • System.String

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE

PS master:\> Get-UserAgent

Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36

Related Topics

Get-TaskSchedule

Returns one or more task schedule items using the specified criteria.

Syntax

Get-TaskSchedule -Item <Item>

Get-TaskSchedule -Path <String>

Get-TaskSchedule [[-Database] <Database>] [[-Name] <String>]

Detailed Description

The Get-TaskSchedule command returns one or more task schedule items, based on name/database filter, path or simply converting a Sitecore item.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Item <Item>

Task item to be converted.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-Path <String>

Path to the item to be returned as Task Schedule.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-Database <Database>

Database containing the task items to be returned. If not provided all databases will be considered for filtering using the "Name" parameter.

Aliases

Required?

false

Position?

2

Default Value

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-Name <String>

Task filter - supports wildcards. Works with "Database" parameter to narrow tassk to only single database.

Aliases

Required?

false

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Sitecore.Tasks.ScheduleItem

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

PS master:\> Get-TaskSchedule
Name                             Database        Active   Auto Remove  Is Due   Expired  Completed    Last Run               Next Run
----                             --------        ------   -----------  ------   -------  ---------    --------               --------
__Task Schedule                  master          True     False        True     False    False        0001-01-01 00:00:00    0001-01-01 00:00:00
Check Bounced Messages           master          True     False        False    False    False        2014-07-29 10:18:43    2014-07-29 22:48:43
Check DSN Messages               master          True     False        False    False    False        2014-07-29 10:19:18    2014-07-29 22:49:18
Clean Confirmation IDs           master          True     False        False    False    False        2014-07-28 22:14:30    2014-07-31 02:14:30
Clean Message History            master          True     False        False    False    False        2014-07-29 10:19:18    2014-07-29 22:49:18
Close Outdated Connections       master          True     False        False    False    False        2014-07-29 12:30:22    2014-07-29 13:30:22
Test-PowerShell                  master          True     False        False    False    False        2014-07-28 14:30:06    2014-08-01 17:32:07
__Task Schedule                  web             True     False        True     False    False        0001-01-01 00:00:00    0001-01-01 00:00:00
Check Bounced Messages           web             True     False        True     False    False        2013-11-04 08:36:22    2013-11-04 21:06:22
Check DSN Messages               web             True     False        True     False    False        2013-11-04 08:36:22    2013-11-04 21:06:22
Clean Confirmation IDs           web             True     False        False    False    False        2013-11-04 08:36:22    2013-11-04 21:36:22
Clean Message History            web             True     False        True     False    False        2013-11-04 08:36:22    2013-11-04 21:06:22
Close Outdated Connections       web             True     False        True     False    False        2013-11-04 09:36:23    2013-11-04 10:36:23
Test-PowerShell                  web             True     False        True     False    False        2013-11-04 09:46:29    2013-11-04 09:46:30

EXAMPLE 2

PS master:\> Get-TaskSchedule -Name "*Check*"
Name                             Database        Active   Auto Remove  Is Due   Expired  Completed    Last Run               Next Run
----                             --------        ------   -----------  ------   -------  ---------    --------               --------
Check Bounced Messages           master          True     False        False    False    False        2014-07-29 10:18:43    2014-07-29 22:48:43
Check DSN Messages               master          True     False        False    False    False        2014-07-29 10:19:18    2014-07-29 22:49:18
Check Bounced Messages           web             True     False        True     False    False        2013-11-04 08:36:22    2013-11-04 21:06:22
Check DSN Messages               web             True     False        True     False    False        2013-11-04 08:36:22    2013-11-04 21:06:22

EXAMPLE 3

PS master:\> Get-TaskSchedule -Name "*Check*" -Database "master"
Name                             Database        Active   Auto Remove  Is Due   Expired  Completed    Last Run               Next Run
----                             --------        ------   -----------  ------   -------  ---------    --------               --------
Check Bounced Messages           master          True     False        False    False    False        2014-07-29 10:18:43    2014-07-29 22:48:43
Check DSN Messages               master          True     False        False    False    False        2014-07-29 10:19:18    2014-07-29 22:49:18

Related Topics

Get-SpeModule

Returns the object that describes a Sitecore PowerShell Extensions Module

Syntax

Get-SpeModule -Item <Item>

Get-SpeModule -Path <String>

Get-SpeModule -Id <String> -Database <String>

Get-SpeModule -Database <String>

Get-SpeModule [-Database <String>] -Name <String>

Detailed Description

The Get-SpeModule command returns the object that describes a Sitecore PowerShell Extensions Module.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Item <Item>

A script or library item that is defined within the module to be returned.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-Path <String>

Path to a script or library item that is defined within the module to be returned.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Id <String>

Id of a script or library item that is defined within the module to be returned.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Database <String>

Database containing the module to be returned.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-Name <String>

Name fo the module to return. Supports wildcards.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

    System.String

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Spe.Core.Modules.Module

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

Return all modules defined in the provided database

PS master:\> Get-SpeModule -Database (Get-Database "master")

EXAMPLE 2

Return all modules defined in the master database Matching the "Content*" wildcard

PS master:\> Get-SpeModule -Database (Get-Database "master")

EXAMPLE 3

Return the module the piped script belongs to

PS master:\> Get-item "master:\system\Modules\PowerShell\Script Library\Copy Renderings\Content Editor\Context Menu\Layout\Copy Renderings" |  Get-SpeModule

Related Topics

Get-ItemField

Retrieves item fields as either names or fields or template fields.

Syntax

Get-ItemField [-Item] <Item> [-IncludeStandardFields] [-ReturnType <Name | Field | TemplateField>] [-Name <String[]>] [-Language <String[]>]

Get-ItemField [-Path] <String> [-IncludeStandardFields] [-ReturnType <Name | Field | TemplateField>] [-Name <String[]>] [-Language <String[]>]

Get-ItemField -Id <String> [-Database <String>] [-IncludeStandardFields] [-ReturnType <Name | Field | TemplateField>] [-Name <String[]>] [-Language <String[]>]

Detailed Description

Retrieves item fields as either names or fields or template fields.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-IncludeStandardFields <SwitchParameter>

Includes fields that are defined on "Standard template"

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ReturnType <ReturnValue>

Determines type returned. The possible values include:

  • Name - strings with field names.

  • Field - fields on the item

  • TemplateField - template fields.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Name <String[]>

Array of names to include - supports wildcards.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Language <String[]>

Language that will be analysed. If not specified the current user language will be used. Globbing/wildcard supported.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Item <Item>

The item to be analysed.

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-Path <String>

Path to the item to be analysed.

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Id <String>

Id of the item to be analysed.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Database <String>

Database containing the item to be analysed - can work with Language parameter to narrow the publication scope.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Sitecore.Data.Items.Item

    Sitecore.Data.Templates.TemplateField

    Sitecore.Data.Fields.Field

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

Get list of names of non standard fields from /sitecore/content/home item

PS master:\> Get-ItemField -Path master:\content\home

Text
Title
Image

EXAMPLE 2

Get list of fields including standard fields from /sitecore/content/home item and list their Name, DisplayName, SectionDisplayName and Description in a table.

PS master:\> Get-Item master:\content\home | Get-ItemField -IncludeStandardFields -ReturnType Field -Name "*" | ft Name, DisplayName, SectionDisplayName, Description -auto

Name                                DisplayName                        SectionDisplayName Description
----                                -----------                        ------------------ -----------
__Revision                          Revision                           Statistics
__Standard values                   __Standard values                  Advanced
__Updated by                        Updated by                         Statistics
__Validate Button Validation Rules  Validation Button Validation Rules Validation Rules
__Created                           Created                            Statistics
__Thumbnail                         Thumbnail                          Appearance
__Insert Rules                      Insert Rules                       Insert Options
__Short description                 Short description                  Help
__Created by                        Created by                         Statistics
__Presets                           Presets                            Layout
Text                                Text                               Data               The text is the main content of the document.

Related Topics

Get-SpeModuleFeatureRoot

Returns the library item or path to the library where scripts for a particular integration point should be located for a specific module.

Syntax

Get-SpeModuleFeatureRoot [-Module <Module>] [-ReturnPath] [-Feature] <String>

Detailed Description

The Get-SpeModuleFeatureRoot command returns library item or path to the library where scripts for a particular integration point should be located for a specific module.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Module <Module>

Module for which the feature root library should be returned. If not provided the feature root will be returned for all modules.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-ReturnPath <SwitchParameter>

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Feature <String>

Feature for which the root library should be provided. If root item does not exist and -ReturnPath parameter is not specified - nothing will be returned, If -ReturnPath parameter is provided the path in which the feature root should be located will be returned

Valid features:

  • contentEditorContextMenu

  • contentEditorGutters

  • contentEditorRibbon

  • controlPanel

  • functions

  • listViewExport

  • listViewRibbon

  • pipelineLoggedIn

  • pipelineLoggingIn

  • pipelineLogout

  • toolbox

  • startMenuReports

  • eventHandlers

  • webAPI

  • pageEditorNotification

  • isePlugi

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Sitecore.Data.Items.Item

    System.String

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

Return the library item for "Content Editor Context Menu"

$module = Get-SpeModule -Name "Copy Renderings"
Get-SpeModuleFeatureRoot -Feature contentEditorContextMenu -Module $module

EXAMPLE 2

Return the Path to where "List View Export" scripts would be located if this feature was defined

$module = Get-SpeModule -Name "Copy Renderings"
Get-SpeModuleFeatureRoot -Module $module -Feature listViewExport -ReturnPath

Related Topics

Get-SitecoreJob

Returns list of the current sitecore jobs

Syntax

Get-SitecoreJob

Detailed Description

The Get-SitecoreJob command returns the list of the currently running jobs of Sitecore.

© 2010-2019 Implemented by Vangasewinkel Benjamin using the Adam Najmanowicz, Michael West Sitecore PowerShell Extensions. All rights reserved.

Parameters

None

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Sitecore.Jobs.Job

Notes

Help Author: Vangansewinkel Benjamin

Examples

EXAMPLE 1

PS master:\> Get-SitecoreJob

Category     : PowerShell
Handle       : b62d9129-298a-4630-bb37-d725e5ce3bbf;DCI5CG6011F3Y-sc81u3contact
IsDone       : True
Name         : PowerShell-ca2a0179-78c5-02a4-5970-17e4909752b0-{347EBAF8-6BE2-4ABC-91D0-36B36FCF414B}
Options      : Sitecore.Jobs.JobOptions
Status       : Sitecore.Jobs.JobStatus
WaitHandle   : System.Threading.ManualResetEvent
QueueTime    : 11/13/2017 1:03:18 PM
MessageQueue : Sitecore.Jobs.AsyncUI.MessageQueue

Category     : Indexing
Handle       : dca83fc7-def7-4564-ac44-987e79ffc3cd;DCI5CG6011F3Y-sc81u3contact
IsDone       : True
Name         : Index_Update_IndexName=sitecore_analytics_index
Options      : Sitecore.Jobs.JobOptions
Status       : Sitecore.Jobs.JobStatus
WaitHandle   : System.Threading.ManualResetEvent
QueueTime    : 11/13/2017 1:03:29 PM
MessageQueue : Sitecore.Jobs.AsyncUI.MessageQueue

Category     : PowerShell
Handle       : de0a1dce-45f7-44fb-81b5-02b402c1f614;DCI5CG6011F3Y-sc81u3contact
IsDone       : False
Name         : PowerShell-ca2a0179-78c5-02a4-5970-17e4909752b0-{47666A58-890B-4D13-8F15-3348643750E4}
Options      : Sitecore.Jobs.JobOptions
Status       : Sitecore.Jobs.JobStatus
WaitHandle   : System.Threading.ManualResetEvent
QueueTime    : 11/13/2017 1:03:29 PM
MessageQueue : Sitecore.Jobs.AsyncUI.MessageQueue

EXAMPLE 2

PS master:\> $jobs = Get-SitecoreJob
PS master:\> $jobs[0].Status

Category     : PowerShell
Handle       : c9215f66-ce60-49e5-9620-bf1ec51b6ef4;DCI5CG6011F3Y-sc81u3contact
IsDone       : False
Name         : PowerShell-ca2a0179-78c5-02a4-5970-17e4909752b0-{DF4895A6-3EBB-4A2A-9756-3A0EF4B96396}
Options      : Sitecore.Jobs.JobOptions
Status       : Sitecore.Jobs.JobStatus
WaitHandle   : System.Threading.ManualResetEvent
QueueTime    : 11/13/2017 1:05:54 PM
MessageQueue : Sitecore.Jobs.AsyncUI.MessageQueue

EXAMPLE 3

PS master:\> Get-SitecoreJob | Show-ListView -Property "Category", "IsDone", "Name", "QueueTime", `
    @{Label="Status Expiry"; Expression={$_.Status.Expiry} },
    @{Label="Status Failed"; Expression={$_.Status.Failed} },
    @{Label="Status State"; Expression={$_.Status.State} },
    @{Label="Status Processed"; Expression={$_.Status.Processed} },
    @{Label="Status Total"; Expression={$_.Status.Total} },
    @{Label="Status Message"; Expression={$_.Status.Messages} }

Related Topics

Get-ItemTemplate

Returns the item template and its base templates.

Syntax

Get-ItemTemplate [-Item] <Item> [-Recurse]

Get-ItemTemplate [-Path] <String> [-Recurse]

Get-ItemTemplate -Id <String> [-Database <String>] [-Recurse]

Detailed Description

The Get-ItemTemplate command returns the item template and its base templates.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Recurse <SwitchParameter>

Return the template the item is based on and all of its base templates.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Item <Item>

The item to be analysed.

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-Path <String>

Path to the item to be analysed.

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Id <String>

Id of the item to be analysed.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Database <String>

Database containing the item to be analysed - required if item is specified with Id.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Sitecore.Data.Items.TemplateItem

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

Get template of /sitecore/conent/home item

PS master:\> Get-ItemTemplate -Path master:\content\home

       BaseTemplates  : {Standard template}
       Fields         : {__Context Menu, __Display name, __Editor, __Editors...}
       FullName       : Sample/Sample Item
       Key            : sample item
       OwnFields      : {Title, Text, Image, State...}
       StandardValues : Sitecore.Data.Items.Item
       Database       : master
       DisplayName    : Sample Item
       Icon           : Applications/16x16/document.png
       ID             : {76036F5E-CBCE-46D1-AF0A-4143F9B557AA}
       InnerItem      : Sitecore.Data.Items.Item
       Name           : Sample Item

EXAMPLE 2

Get template of /sitecore/conent/home item and all of the templates its template is based on then format it to only show the template name, path and Key

PS master:\> Get-Item -Path master:/content/Home | Get-ItemTemplate -Recurse | ft Name, FullName, Key -auto

       Name              FullName                                 Key
       ----              --------                                 ---
       Sample Item       Sample/Sample Item                       sample item
       Standard template System/Templates/Standard template       standard template
       Advanced          System/Templates/Sections/Advanced       advanced
       Appearance        System/Templates/Sections/Appearance     appearance
       Help              System/Templates/Sections/Help           help
       Layout            System/Templates/Sections/Layout         layout
       Lifetime          System/Templates/Sections/Lifetime       lifetime
       Insert Options    System/Templates/Sections/Insert Options insert options
       Publishing        System/Templates/Sections/Publishing     publishing
       Security          System/Templates/Sections/Security       security
       Statistics        System/Templates/Sections/Statistics     statistics
       Tasks             System/Templates/Sections/Tasks          tasks
       Validators        System/Templates/Sections/Validators     validators
       Workflow          System/Templates/Sections/Workflow       workflow

Related Topics

Invoke-JavaScript

Syntax

Invoke-JavaScript [-Script] <String>

Detailed Description

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Script <String>

New-ItemClone

Creates a new item clone based on the item provided.

Syntax

New-ItemClone [-Item] <Item> -Destination <Item> [-Name <String>] [-Recurse]

New-ItemClone [-Path] <String> -Destination <Item> [-Name <String>] [-Recurse]

New-ItemClone -Id <String> [-Database <String>] -Destination <Item> [-Name <String>] [-Recurse]

Detailed Description

Creates a new item clone based on the item provided.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Destination <Item>

Parent item under which the clone should be created.

-Name <String>

Name of the item clone.

-Recurse <SwitchParameter>

Add the parameter to clone thw whole branch rather than a single item.

-Item <Item>

The item to be cloned.

-Path <String>

Path to the item to be cloned.

-Id <String>

Id of the item to be cloned

-Database <String>

Database of the item to be cloned if item is specified through its ID.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Sitecore.Data.Items.Item

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE

Clone /sitecore/content/home/ under /sitecore/content/new-target/ with the "New Home" name.

Related Topics

  • New-Item

Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases

https://github.com/SitecorePowerShell/Console/
Start-TaskSchedule
https://github.com/SitecorePowerShell/Console/
https://www.youtube.com/watch?v=N3xgZcU9FqQ&list=PLph7ZchYd_nCypVZSNkudGwPFRqf1na0b&index=9
Get-SpeModuleFeatureRoot
https://blog.najmanowicz.com/2014/11/01/sitecore-powershell-extensions-3-0-modules-proposal/
https://github.com/SitecorePowerShell/Console/
Get-ItemTemplate
Reset-ItemField
https://github.com/SitecorePowerShell/Console/
Get-SpeModule
https://blog.najmanowicz.com/2014/11/01/sitecore-powershell-extensions-3-0-modules-proposal/
https://github.com/SitecorePowerShell/Console/
https://github.com/SitecorePowerShell/Console/
https://www.youtube.com/watch?v=N3xgZcU9FqQ&list=PLph7ZchYd_nCypVZSNkudGwPFRqf1na0b&index=9
Get-ItemField
Set-ItemTemplate
Add-BaseTemplate
Remove-BaseTemplate
https://github.com/SitecorePowerShell/Console/

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

PS master:\> $newTarget = Get-Item master:\content\new-target\
PS master:\> New-ItemClone -Path master:\content\home -Destination $newTarget -Name "New Home"

Receive-ItemCloneNotification

Syntax

Receive-ItemCloneNotification [-Notification <Notification>] -Notification <Notification> -Action <None | Accept | Reject | Dismiss> [-NotificationType <Notification | ChildCreatedNotification | FieldChangedNotification | FirstVersionAddedNotification | ItemMovedChildCreatedNotification | ItemMovedChildRemovedNotification | ItemMovedNotification | ItemTreeMovedNotification | ItemVersionNotification | OriginalItemChangedTemplateNotification | VersionAddedNotification>] [-Language <String[]>]
Receive-ItemCloneNotification [-Item] <Item> -Notification <Notification> -Action <None | Accept | Reject | Dismiss> [-NotificationType <Notification | ChildCreatedNotification | FieldChangedNotification | FirstVersionAddedNotification | ItemMovedChildCreatedNotification | ItemMovedChildRemovedNotification | ItemMovedNotification | ItemTreeMovedNotification | ItemVersionNotification | OriginalItemChangedTemplateNotification | VersionAddedNotification>] [-Language <String[]>]
Receive-ItemCloneNotification [-Path] <String> -Notification <Notification> -Action <None | Accept | Reject | Dismiss> [-NotificationType <Notification | ChildCreatedNotification | FieldChangedNotification | FirstVersionAddedNotification | ItemMovedChildCreatedNotification | ItemMovedChildRemovedNotification | ItemMovedNotification | ItemTreeMovedNotification | ItemVersionNotification | OriginalItemChangedTemplateNotification | VersionAddedNotification>] [-Language <String[]>]
Receive-ItemCloneNotification -Id <String> [-Database <String>] -Notification <Notification> -Action <None | Accept | Reject | Dismiss> [-NotificationType <Notification | ChildCreatedNotification | FieldChangedNotification | FirstVersionAddedNotification | ItemMovedChildCreatedNotification | ItemMovedChildRemovedNotification | ItemMovedNotification | ItemTreeMovedNotification | ItemVersionNotification | OriginalItemChangedTemplateNotification | VersionAddedNotification>] [-Language <String[]>]

Detailed Description

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Notification <Notification>

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-Action <NotificationAction>

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-NotificationType <NotificationType>

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Language <String[]>

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Item <Item>

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-Path <String>

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Id <String>

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Database <String>

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Examples

EXAMPLE 1

The following gets the cloned Item, returns the available notifications, and finally accepts the notifications.

$clonedItem = Get-Item -Path "master:" -ID "{9F158637-52C2-4005-8329-21527685CB71}"
$clonedItem  | Get-ItemCloneNotification | Receive-ItemCloneNotification -Action Accept

EXAMPLE 2

The following gets the cloned Item, returns the available notifications, and finally rejects the notifications.

$clonedItem = Get-Item -Path "master:" -ID "{9F158637-52C2-4005-8329-21527685CB71}"
$clonedItem  | Get-ItemCloneNotification | Receive-ItemCloneNotification -Action Reject
Get-ItemClone
ConvertFrom-ItemClone
https://github.com/SitecorePowerShell/Console/
https://github.com/SitecorePowerShell/Console/issues/218

Invoke-ShellCommand

Executes Sitecore Shell command for an item. This command used to be named Execute-ShellCommand - a matching alias added for compatibility with older scripts.

Syntax

Invoke-ShellCommand [-Item] <Item> [-Name] <String> [-Language <String[]>]

Invoke-ShellCommand [-Path] <String> [-Name] <String> [-Language <String[]>]

Invoke-ShellCommand -Id <String> [-Database <String>] [-Name] <String> [-Language <String[]>]

Detailed Description

Executes Sitecore Shell command for an item. e.g. opening dialogs or performing commands that you can find in the Content Editor ribbon or context menu.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Aliases

The following abbreviations are aliases for this cmdlet:

  • Execute-ShellCommand

Parameters

-Name <String>

Name of the sitecore command e.g. "item:publishingviewer"

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Language <String[]>

Language that will be used as source language. If not specified the current user language will be used. Globbing/wildcard supported.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Item <Item>

The item to be sent to the command.

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-Path <String>

Path to the item to be sent to the command - additionally specify Language parameter to fetch different item language than the current user language.

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Id <String>

Id of the the item to be sent to the command - additionally specify Language parameter to fetch different item language than the current user language.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Database <String>

Database containing the item to be sent to the command - can work with Language parameter to narrow the publication scope.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Sitecore.Data.Items.Item

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

Launch Publishing Viewer for /sitecore/content/home item.

PS master:\> Get-Item master:\content\home\ | Invoke-ShellCommand "item:publishingviewer"

EXAMPLE 2

Initiate /sitecore/content/home item duplication.

PS master:\> Get-Item master:/content/home | Invoke-ShellCommand "item:duplicate"

EXAMPLE 3

Show properties of the /sitecore/content/home item.

PS master:\> Get-Item master:/content/home | Invoke-ShellCommand "contenteditor:properties"

Related Topics

Invoke-Workflow

Executes Workflow action for an item. This command used to be named Execute-Workflow - a matching alias added for compatibility with older scripts.

Syntax

Invoke-Workflow [-Item] <Item> [-CommandName <String>] [-Comments <String>] [-Language <String[]>]

Invoke-Workflow [-Path] <String> [-CommandName <String>] [-Comments <String>] [-Language <String[]>]

Invoke-Workflow -Id <String> [-Database <String>] [-CommandName <String>] [-Comments <String>] [-Language <String[]>]

Detailed Description

Executes Workflow action for an item. If the workflow action could not be performed for any reason - an appropriate error will be raised.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Aliases

The following abbreviations are aliases for this cmdlet:

  • Execute-Workflow

Parameters

-CommandName <String>

Namer of the workflow command.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Comments <String>

Comment to be saved in the history table for the action.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Language <String[]>

Language that will be used as source language. If not specified the current user language will be used. Globbing/wildcard supported.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Item <Item>

The item to have the workflow action executed.

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-Path <String>

Path to the item to have the workflow action executed - additionally specify Language parameter to fetch different item language than the current user language.

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Id <String>

Id of the the item to have the workflow action executed - additionally specify Language parameter to fetch different item language than the current user language.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Database <String>

Database containing the item to have the workflow action executed - can work with Language parameter to narrow the publication scope.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

Submit item to approval, item gotten from path

PS master:\> Invoke-Workflow -Path master:/content/home -CommandName "Submit" -Comments "Automated"

EXAMPLE 2

Reject item, item gotten from pipeline

PS master:\> Get-Item master:/content/home | Invoke-Workflow -CommandName "Reject" -Comments "Automated"

Related Topics

Import-Function

Imports a function script from the script library's "Functions" folder.

Syntax

Import-Function [-Name] <String> [-Library <String>] [-Module <String>]

Detailed Description

The Import-Function command imports a function script from the script library's "Functions" folder.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Name <String>

Name of the script in the "Functions" library or one of its sub-libraries.

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Library <String>

Name of the library withing the "Functions" library. Provide this name to disambiguate a script from other scripts of the same name that might exist in multiple sub-librarties of the Functions library.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Module <String>

Name of the module "Functions" are going to be taken from. Provide this name to disambiguate a script from other scripts of the same name that might exist in multiple Modules.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Outputs

The output type is the type of the objects that the cmdlet emits.

  • System.Object

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE

The following imports a Resolve-Error function that you may later use to get a deeper understanding of a problem with script should one occur by xecuting the "Resolve-Error" command that was imported as a result of the execution of the following line

PS master:\> Import-Function -Name Resolve-Error

Related Topics

Receive-File

Shows a dialog to users allowing to upload files to either server file system or items in media library.

Syntax

Receive-File [-Description <String>] [-ParentItem] <Item> [-Title <String>] [-CancelButtonName <String>] [-OkButtonName <String>] [-Versioned] [-Language <String>] [-Overwrite] [-Unpack] [-Width <Int32>] [-Height <Int32>]

Receive-File [-Description <String>] [-Path] <String> [-Title <String>] [-CancelButtonName <String>] [-OkButtonName <String>] [-Overwrite] [-Unpack] [-Width <Int32>] [-Height <Int32>]

Receive-File [-ParentItem] <Item> -AdvancedDialog [-Width <Int32>] [-Height <Int32>]

Detailed Description

Executing this command with file path on the server (provided as -Path parameter) provides script users with means to upload a file from their computer. Executing it for an Item located in Sitecore Media library (provided as -ParentItem) allows the user to upload the file as a child to that item. If the file has been uploaded the dialog returns path to the file (in case of file system storage) or Item that has been created if the file was uplaoded to media library.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Description <String>

Dialog description displayed below the dialog title.

-ParentItem <Item>

The item under which the uploaded media items should be stored.

-Path <String>

Path to the folder where uploaded file should be stored.

-Title <String>

Dialog title - shown at the top of the dialog.

-CancelButtonName <String>

Text shown on the cancel button.

-OkButtonName <String>

Text shown on the OK button.

-Versioned <SwitchParameter>

Indicates that the Media item should be created as a Versioned media item.

-Language <String>

Specifies the language in which the media item should be created. if not specified - context language is selected.

-Overwrite <SwitchParameter>

indicates that the upload should overwrite a file or a media item if that one exists. Otherwise a file with a non-confilicting name or a sibling media item is created.

-Unpack <SwitchParameter>

Indicates that the uplaod is expected to be a ZIP file which should be unpacked when it's received.

-AdvancedDialog <SwitchParameter>

Shows advanced dialog where user can upload multiple media items and select if the uploaded items are versioned, overwritten and unpacked.

-Width <Int32>

Dialog width.

-Height <Int32>

Dialog width.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

    System.String

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Sitecore.Data.Items.Item

    System.String

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

Upload text.txt file to server disk drive. A new file is created with a non-conflicting name and the path to it is returned

EXAMPLE 2

Upload text.txt file to media library under the 'master:\media library\Files' item A new media item is created and returned

EXAMPLE 3

Upload text.txt file to media library under the 'master:\media library\Files' item using advanced dialog. A new media item is created but "undetermined" is returned as the dialog does not return the results.

EXAMPLE 4

Upload text.txt file to media library under the 'master:\media library\Files' item. A new versioned media item in Danish language is created and returned. If the media item existed - it will be overwritten.

Related Topics

Remove-BaseTemplate

Remove one or more base templates from a template item.

Syntax

Remove-BaseTemplate -Item <Item> -TemplateItem <TemplateItem[]>

Remove-BaseTemplate -Item <Item> -Template <String[]>

Remove-BaseTemplate -Path <String> -TemplateItem <TemplateItem[]>

Remove-BaseTemplate -Path <String> -Template <String[]>

Remove-BaseTemplate -Id <String> -TemplateItem <TemplateItem[]>

Remove-BaseTemplate -Id <String> -Template <String[]>

Remove-BaseTemplate [-Database <String>]

Detailed Description

The Remove-BaseTemplate command removes one or more base templates from a template item.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Item <Item>

The item to remove the base template from.

-Path <String>

Path to the item to remove the base template from.

-Id <String>

Id of the item to remove the base template from.

-TemplateItem <TemplateItem[]>

Sitecore item or list of items of base templates to remove.

-Template <String[]>

Path representing the template item to remove as a base template. This must be of the same database as the item to be altered. Note that this parameter only supports a single template.

-Database <String>

Database containing the item to remove the base template from - required if item is specified with Id.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Notes

Help Author: Adam Najmanowicz, Michael West, Alex Washtell

Examples

EXAMPLE 1

Remove base template of /sitecore/templates/User Defined/BaseTemplate from a template, using a path.

EXAMPLE 2

Remove multiple base templates from a template, using items.

Related Topics

Read-Variable

Prompts user to provide values for variables required by the script to perform its operation.

Syntax

Detailed Description

Prompts user to provide values for variables required by the script to perform its operation. If user selects the "OK" button the command will return 'ok' as its value. If user selects the "Cancel" button or closes the window with the "x" button at the top-right corner of the dialog the command will return 'cancel' as its value.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Parameters <Object[]>

Specifies the variables that value should be provided by the user. Each variable definition can have the following structure:

  • Name - the name of the PowerShell variable - without the $ sign

  • Value - the initial value of the variable - if the variable have not been created prior to launching the dialog - this will be its value unless the user changes it. if Value is not specified - the existing variable name will be used.

  • Title - The title for the variable shown above the variable editor.

  • Tooltip - The hint describing the parameter further - if the -ShowHints parameter is provided this value will show between the Variable Title and the variable editor.

  • Editor - If the default editor selected does not provide the functionality expected - you can specify this value to customize it (see examples)

  • Tab - if this parameter is specified on any Variable the multi-tab dialog will be used instead of a simple one. Provide the tab name on which the variable editor should appear.

Variable type specific:

  • Root - for some Item selecting editors you can provide this to limit the selection to only part of the tree

  • Source - for some Item selecting editors you can provide this to parametrize the item selection editor. (Refer to examples for some sample usages)

  • Lines - for String variable you can select this parameter if you want to present the user with the multiline editor. The for this parameter is the number of lines that the editor will be configured with.

  • Domain - for user and role selectors you can limit the users & roles presented to only the domain - specified)

-Description <String>

Dialog description displayed below the dialog title.

-CancelButtonName <String>

Text shown on the cancel button.

-OkButtonName <String>

Text shown on the OK button.

-ShowHints <SwitchParameter>

Specifies whether the variable hints should be displayed. Hints are shown below each the variable title but above the variable editing control.

-Validator <ScriptBlock>

-Title <String>

Dialog title - shown at the top of the dialog.

-Width <Int32>

Dialog width.

-Height <Int32>

Dialog width.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Outputs

The output type is the type of the objects that the cmdlet emits.

  • System.String

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

The following provides a dialog with a dropdown of options, and how to read the selected value.

EXAMPLE 2

Following is an example of a simple dialog asking user for various variable types.

The type of some of the controls displayed to the user are iferred from the variable type (like the $item variable or DateTime) The editors for some other are set by providing the "editor" value

EXAMPLE 3

Following is an example of a multi tabbed dialog asking user for various variable types.

The type of some of the controls displayed to the user are inferred from the variable type (like the $item variable or DateTime) The editors for some other are set by providing the "editor" value

Related Topics

Remove-ArchiveItem

Removes items permanently from the specified archive.

Syntax

Detailed Description

The Remove-ArchiveItem command permanently removes entries from specified archive.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Archive <Archive>

Specifies the archive to use when determining which ArchiveEntry items to remove. Use Get-Archive to find the appropriate archive.

-ItemId <ID>

Specifies the ID for the original item that should be processed. This is NOT the ArchivalId.

-Identity <AccountIdentity>

Specifies the user responsible for moving the item to the archive.

-ArchiveItem <ArchiveEntry[]>

Specific items from the archive may be deleted when using this parameter.

Inputs

  • AccountIdentity

  • Sitecore.Data.Archiving.ArchiveEntry

Outputs

The output type is the type of the objects that the cmdlet emits.

  • None.

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

The following removes items matching the ItemId found in the specified archive.

EXAMPLE 2

The following removes items from the recycle bin by the user found in the specified archive.

EXAMPLE 3

The following removes all items from the recycle bin found in the specified archive.

Related Topics

  • Get-ArchiveItem

  • Restore-ArchiveItem

  • Remove-Item

  • Remove-ItemVersion

Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases

Aliases
Aliases
Aliases
Aliases
Aliases
Aliases

Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases

Aliases
Aliases
Aliases
Aliases

https://github.com/SitecorePowerShell/Console/
https://github.com/SitecorePowerShell/Console/
Invoke-Script
https://github.com/SitecorePowerShell/Console/

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

PS master:\> Receive-File -Path "C:\temp\upload"
C:\temp\upload\text_029.txt
PS master:\> Receive-File -ParentItem (get-item "master:\media library\Files") 
Name Children Languages Id                                     TemplateName
---- -------- --------- --                                     ------------
text False    {en}      {7B11CE12-C0FC-4650-916C-2FC76F3DCAAF} File
PS master:\> Receive-File (get-item "master:\media library\Files") -AdvancedDialog
undetermined
PS master:\> Receive-File -ParentItem (get-item "master:\media library\Files") -Overwrite -Language "da" -Versioned
Name Children Languages Id                                     TemplateName
---- -------- --------- --                                     ------------
text False    {en, da}  {307BCF7D-27FD-46FC-BE83-D9ED640CB09F} File

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

PS master:\> Remove-BaseTemplate -Path "master:/sitecore/content/User Defined/Page" -Template "/sitecore/templates/User Defined/BaseTemplate"
PS master:\> $baseA = Get-Item -Path master:/sitecore/content/User Defined/BaseTemplateA
       PS master:\> $baseB = Get-Item -Path master:/sitecore/content/User Defined/BaseTemplateB
       PS master:\> Remove-BaseTemplate -Path "master:/sitecore/content/User Defined/Page" -TemplateItem @($baseA, $baseB)
Read-Variable [-Parameters <Object[]>] [-Description <String>] [-CancelButtonName <String>] [-OkButtonName <String>] [-ShowHints] [-Validator <ScriptBlock>] [-Title <String>] [-Width <Int32>] [-Height <Int32>]

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

$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
}

$result = Read-Variable @props

if($result -eq "ok")
{
    Write-Host "You chose: $($selectedOption)"
}
$item = Get-Item master:\content\home
$result = Read-Variable -Parameters `
    @{ Name = "someText"; Value="Some Text"; Title="Single Line Text"; Tooltip="Tooltip for singleline"; Placeholder="You see this when text box is empty"}, 
    @{ Name = "multiText"; Value="Multiline Text"; Title="Multi Line Text"; lines=3; Tooltip="Tooltip for multiline"; Placeholder="You will see this when text box is empty"}, 
    @{ Name = "from"; Value=[System.DateTime]::Now.AddDays(-5); Title="Start Date"; Tooltip="Date since when you want the report to run"; Editor="date time"}, 
    @{ Name = "user"; Value=$me; Title="Select User"; Tooltip="Tooltip for user"; Editor="user multiple"},
    @{ Name = "item"; Title="Start Item"; Root="/sitecore/content/"} `
    -Description "This Dialog shows less editors, it doesn't need tabs as there is less of the edited variables" `
    -Title "Initialise various variable types (without tabs)" -Width 500 -Height 480 -OkButtonName "Proceed" -CancelButtonName "Abort"
$item = Get-Item master:\content\home
$result = Read-Variable -Parameters `
    @{ Name = "silent"; Value=$true; Title="Proceed Silently"; Tooltip="Check this if you don't want to be interrupted"; Tab="Simple"}, 
    @{ Name = "someText"; Value="Some Text"; Title="Text"; Tooltip="Just a single line of Text"; Tab="Simple"; Placeholder="You see this when text box is empty"}, 
    @{ Name = "multiText"; Value="Multiline Text"; Title="Longer Text"; lines=3; Tooltip="You can put multi line text here"; Tab="Simple"; Placeholder="You see this when text box is empty"}, 
    @{ Name = "number"; Value=110; Title="Integer"; Tooltip="I need this number too"; Tab="Simple"}, 
    @{ Name = "fraction"; Value=1.1; Title="Float"; Tooltip="I'm just a bit over 1"; Tab="Simple"}, 
    @{ Name = "from"; Value=[System.DateTime]::Now.AddDays(-5); Title="Start Date"; Tooltip="Date since when you want the report to run"; Editor="date time"; Tab="Time"}, 
    @{ Name = "fromDate"; Value=[System.DateTime]::Now.AddDays(-5); Title="Start Date"; Tooltip="Date since when you want the report to run"; Editor="date"; Tab="Time"}, 
    @{ Name = "item"; Title="Start Item"; Root="/sitecore/content/"; Tab="Items"}, 
    @{ Name = "items"; Title="Bunch of Templates"; 
        Source="DataSource=/sitecore/templates&DatabaseName=master&IncludeTemplatesForDisplay=Node,Folder,Template,Template Folder&IncludeTemplatesForSelection=Template"; 
        editor="treelist"; Tab="Items"}, 
    @{ Name = "items2"; Title="Bunch of Templates"; 
        Source="DataSource=/sitecore/templates&DatabaseName=master&IncludeTemplatesForDisplay=Node,Folder,Template,Template Folder&IncludeTemplatesForSelection=Template"; 
        editor="multilist"; Tab="More Items"}, 
    @{ Name = "items3"; Title="Pick One Template"; 
        Source="DataSource=/sitecore/templates&DatabaseName=master&IncludeTemplatesForDisplay=Node,Folder,Template,Template Folder&IncludeTemplatesForSelection=Template"; 
        editor="droplist"; Tab="More Items"}, 
    @{ Name = "user"; Value=$me; Title="Select User"; Tooltip="Tooltip for user"; Editor="user multiple"; Tab="Rights"}, 
    @{ Name = "role"; Title="Select Role"; Tooltip="Tooltip for role"; Editor="role multiple"; Domain="sitecore"; Tab="Rights"}, `
    @{ Name = "userOrRole"; Title="Select User or Role"; Tooltip="Tooltip for role"; Editor="user role multiple"; Domain="sitecore"; Tab="Rights" } `
    -Description "This Dialog shows all available editors in some configurations, the properties are groupped into tabs" `
    -Title "Initialise various variable types (with tabs)" -Width 600 -Height 640 -OkButtonName "Proceed" -CancelButtonName "Abort" -ShowHints
if($result -ne "ok")
{
    Exit
}
Remove-ArchiveItem -Archive <Archive> [-ItemId <ID>]
Remove-ArchiveItem -Archive <Archive> [-Identity <AccountIdentity>]
Remove-ArchiveItem -Archive <Archive> [-ArchiveItem <ArchiveEntry[]>]

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

$database = Get-Database -Name "master"
$archiveName = "recyclebin"
$archive = Get-Archive -Database $database -Name $archiveName
Remove-ArchiveItem -Archive $archive -ItemId "{1BB32980-66B4-4ADA-9170-10A9D3336613}"
$database = Get-Database -Name "master"
$archiveName = "recyclebin"
$archive = Get-Archive -Database $database -Name $archiveName
Remove-ArchiveItem -Archive $archive -Identity "sitecore\admin"
$database = Get-Database -Name "master"
$archiveName = "recyclebin"
$archive = Get-Archive -Database $database -Name $archiveName
Get-ArchiveItem -Archive $archive | Remove-ArchiveItem
image
image
Send-File
Out-Download
https://github.com/SitecorePowerShell/Console/
Add-BaseTemplate
Get-ItemTemplate
Set-ItemTemplate
https://github.com/SitecorePowerShell/Console/
Show-Alert
Show-Application
Show-Confirm
Show-FieldEditor
Show-Input
Show-ListView
Show-ModalDialog
Show-YesNoCancel
https://github.com/SitecorePowerShell/Console/
https://github.com/SitecorePowerShell/Console/
image
Toolbox

Restore-ArchiveItem

Restores items to the original database from the specified archive.

Syntax

Restore-ArchiveItem -Archive <Archive> [-WhatIf] [-Confirm]  [<CommonParameters>]
Restore-ArchiveItem -Archive <Archive> [-ItemId <ID>] [-WhatIf] [-Confirm]  [<CommonParameters>]
Restore-ArchiveItem -Archive <Archive> [-Identity <AccountIdentity>] [-WhatIf] [-Confirm]  [<CommonParameters>]
Restore-ArchiveItem -ArchiveItem <ArchiveEntry[]> [-WhatIf] [-Confirm]  [<CommonParameters>]

Detailed Description

The Restore-ArchiveItem command restores entries from specified archive back to the original database.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Archive <Archive>

Specifies the archive to use when determining which ArchiveEntry items to process. Use Get-Archive to find the appropriate archive.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ItemId <ID>

Specifies the ID for the original item that should be processed. This is NOT the ArchivalId.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Identity <AccountIdentity>

Specifies the user responsible for moving the item to the archive.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-ArchiveItem <ArchiveEntry[]>

Specific items from the archive may be restored when using this parameter.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

Inputs

  • AccountIdentity

  • Sitecore.Data.Archiving.ArchiveEntry

Outputs

The output type is the type of the objects that the cmdlet emits.

  • None.

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

The following restores items matching the ItemId found in the specified archive.

$database = Get-Database -Name "master"
$archiveName = "recyclebin"
$archive = Get-Archive -Database $database -Name $archiveName
Restore-ArchiveItem -Archive $archive -ItemId "{1BB32980-66B4-4ADA-9170-10A9D3336613}"

EXAMPLE 2

The following restores items from the recycle bin by the user found in the specified archive.

$database = Get-Database -Name "master"
$archiveName = "recyclebin"
$archive = Get-Archive -Database $database -Name $archiveName
Restore-ArchiveItem -Archive $archive -Identity "sitecore\admin"

EXAMPLE 3

The following restores all items from the recycle bin found in the specified archive.

$database = Get-Database -Name "master"
$archiveName = "recyclebin"
$archive = Get-Archive -Database $database -Name $archiveName
Get-ArchiveItem -Archive $archive | Restore-ArchiveItem

Related Topics

  • Get-ArchiveItem

  • Restore-ArchiveItem

  • Remove-Item

  • Remove-ItemVersion

Send-SheerMessage

Sends a sheer message to the app in which context the script is executing.

Syntax

Send-SheerMessage [-Name] <String> [-GetResult] [-Parameters <Hashtable>]

Detailed Description

Sends a sheer message to the app in which context the script is executing.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Name <String>

Name of the Sheer message to execute.

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-GetResult <SwitchParameter>

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Parameters <Hashtable>

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE

If you execute the following script in the PowerShell ISE the Save dialog will popup

Send-SheerMessage -Name 'ise:save'

Related Topics

Send-File

Allows users to download files from server and file items from media library.

Syntax

Send-File [-Path] <String> [-Message <String>] [-NoDialog] [-ShowFullPath] [-Title <String>] [-Width <Int32>] [-Height <Int32>]

Send-File [-Item] <Item> [-Message <String>] [-NoDialog] [-ShowFullPath] [-Title <String>] [-Width <Int32>] [-Height <Int32>]

Detailed Description

Executing this command with file path on the server provides script users with means to download a file to their computer. Executing it for an Item located in Sitecore Media library allows the user to download the blob stored in that item. If the file has been downloaded the dialog returns "downloaded" string, otherwise "cancelled" is returned.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Aliases

The following abbreviations are aliases for this cmdlet:

  • Download-File

Parameters

-Path <String>

Path to the file to be downloaded. The file has to exist in the Data folder. Files from outside the Data folder are not downloadable.

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-Message <String>

Message to show the user in the download dialog.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Item <Item>

The item to be downloaded.

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-NoDialog <SwitchParameter>

If this parameter is used the Dialog will not be shown but instead the file download will begin immediately.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ShowFullPath <SwitchParameter>

If this parameter is used the Dialog will display full path to the file downloaded in the dialog, otherwise only the file name will be shown.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Title <String>

Download dialog title.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Width <Int32>

Download dialog width.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Height <Int32>

Download dialog height.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Outputs

The output type is the type of the objects that the cmdlet emits.

  • System.String

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

Download File from server disk drive

PS master:\> Send-File -Path "C:\Projects\ZenGarden\Data\packages\Sitecore PowerShell Extensions-6.0.zip"

EXAMPLE 2

Download item from media library

PS master:\> Get-Item "master:/media library/Showcase/awesome_logo" | Send-File -Message "Awesome Logo"

Related Topics

Remove-ItemVersion

Removes Language/Version from a single item or a branch of items

Syntax

Remove-ItemVersion -Language <String[]> [-Version <String[]>] [-ExcludeLanguage <String[]>] [-Path] <String> [-Recurse] [-MaxRecentVersions <Int32>]

Remove-ItemVersion -Language <String[]> [-Version <String[]>] [-ExcludeLanguage <String[]>] -Id <String> [-Database <String>] [-Recurse] [-MaxRecentVersions <Int32>]

Remove-ItemVersion [-Language <String[]>] [-Version <String[]>] [-ExcludeLanguage <String[]>] [-Item] <Item> [-Recurse] [-MaxRecentVersions <Int32>]

Detailed Description

Removes Language/Version from a an Item either sent from pipeline or defined with Path or ID. A single language or a list of languages can be defined using the Language parameter. Language parameter supports globbing so you can delete whole language groups using wildcards.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Aliases

The following abbreviations are aliases for this cmdlet:

  • Remove-ItemLanguage

Parameters

-Recurse <SwitchParameter>

Deleted language versions from the item and all of its children.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Language <String[]>

Language(s) that should be deleted form the provided item(s). A single language or a list of languages can be defined using the parameter. Language parameter supports globbing so you can delete whole language groups using wildcards.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Version <String[]>

Version(s) that should be deleted form the provided item(s). A single version or a list of versions can be defined using the parameter. Version parameter supports globbing so you can delete whole version groups using wildcards.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ExcludeLanguage <String[]>

Language(s) that should NOT be deleted form the provided item(s). A single language or a list of languages can be defined using the parameter. Language parameter supports globbing so you can delete whole language groups using wildcards.

If Language parameter is not is not specified but ExcludeLanguage is provided, the default value of "*" is assumed for Language parameter.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-MaxRecentVersions <Int32>

If provided - trims the selected language to value specified by this parameter.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Item <Item>

The item/version to be processed. You can pipe a specific version of the item for it to be removed.

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-Path <String>

Path to the item to be processed - can work with Language parameter to narrow the publication scope.

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Id <String>

Id of the item to be processed - can work with Language parameter to narrow the publication scope.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Database <String>

Database containing the item to be processed - can work with Language parameter to narrow the publication scope.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Archive <SwitchParameter>

Specifying this switch will move the items to the archive rather than recycle bin.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

Remove Polish and Spanish language from /sitecore/content/home item in the master database

Remove-ItemVersion -Path master:\content\home -Language "pl-pl", "es-es"

EXAMPLE 2

Remove all english based languages defined in /sitecore/content/home item and all of its children in the master database

Remove-ItemVersion -Path master:\content\home -Language "en-*" -Recurse

EXAMPLE 3

Remove all languages except those that are "en" based defined in /sitecore/content/home item and all of its children in the master database

Remove-ItemVersion -Path master:\content\home -ExcludeLanguage "en*" -Recurse

EXAMPLE 4

Trim all languages to 3 latest versions for /sitecore/content/home item and all of its children in the master database

Remove-ItemVersion -Path master:\content\home -Language * -MaxRecentVersions 3 -Recurse

EXAMPLE 5

The following moves the specified item version to the archive.

$itemId = "{72EB19F8-E62A-4B99-80A3-63E03F4FD036}"
Get-Item -Path "master:" -ID $itemId -Version 2 | Remove-ItemVersion -Archive

Related Topics

  • Remove-Item

Show-Alert

Pauses the script and shows an alert to the user.

Syntax

Show-Alert [-Title] <String>

Detailed Description

Pauses the script and shows an alert specified in the -Title to the user. Once user clicks the OK button - script execution resumes.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Title <String>

Text to show the user in the alert dialog.

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE

Related Topics

Show-Application

Executes Sitecore Sheer application.

Syntax

Show-Application [-Application] <String> [[-Parameter] <Hashtable>] [-Icon <String>] [-Modal] [-Title <String>] [-Width <Int32>] [-Height <Int32>]

Detailed Description

Executes Sitecore Sheer application, allows for passing additional parameters, launching it on desktop in cooperative or in Modal mode.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Application <String>

Name of the Application to be executed. Application must be defined in the Core databse.

-Parameter <Hashtable>

Additional parameters passed to the application.

-Icon <String>

Icon of the executed application (used for titlebar and in the Sitecore taskbar on the desktop)

-Modal <SwitchParameter>

Causes the application to show in new browser modal window or modal overlay if used in Sitecore 7.2 or later.

-Title <String>

Title of the window the app opens in.

-Width <Int32>

Width of the modal window.

-Height <Int32>

Height of the modal window.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

Show Content Editor in new window (or as an overlay in modal mode in Sitecore 7.2+) with "/sitecore/templates" item selected.

EXAMPLE 2

Show Content Editor as a new application on desktop with "/sitecore/content/home" item selected.

Related Topics

Restart-Application

Restarts the Sitecore Application pool.

Syntax

Detailed Description

Restarts the Sitecore Application pool.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE

Related Topics

Show-Input

Shows prompt message box asking user to provide a text string.

Syntax

Show-Input [-Prompt] <String> [-DefaultValue <String>] [-Validation <String>] [-ErrorMessage <String>] [-MaxLength <Int32>]

Detailed Description

Shows prompt message box asking user to provide a text string.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Prompt <String>

Prompt message to show in the message box shown to a user.

-DefaultValue <String>

Default value to be provided for the text box.

-Validation <String>

Regex for value validation. If user enters a value that does not validate - en error message defined with the "ErrorMessage" parameter will be shown and user will be asked to enter the value again.

-ErrorMessage <String>

Error message to show when regex validation fails.

-MaxLength <Int32>

Maximum length of the string returned. If user enters a longer value - en error message will be shown and user will be asked to enter the value again.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • System.String

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

Requests that the user provides an email, validates it against a regular expression snd whows an allert if the format is not valid

EXAMPLE 2

Uses Show-Input command to request user a new name for the content item validating the proper characters are used and assigns the result to $newName variable (nothing gets changed)

EXAMPLE 3

Requests that the user provides a string of at most 5 characters

Related Topics

Show-FieldEditor

Shows Field editor for a provided item.

Syntax

Show-FieldEditor -Item <Item> -PreserveSections [-Name <String[]>] [-Title <String>] [-Width <Int32>] [-Height <Int32>] [-IncludeStandardFields]

Show-FieldEditor -Item <Item> [-SectionTitle <String>] [-SectionIcon <String>] [-Name <String[]>] [-Title <String>] [-Width <Int32>] [-Height <Int32>] [-IncludeStandardFields]

Show-FieldEditor -Path <String> [-Language <String[]>] -PreserveSections [-Name <String[]>] [-Title <String>] [-Width <Int32>] [-Height <Int32>] [-IncludeStandardFields]

Show-FieldEditor -Path <String> [-Language <String[]>] [-SectionTitle <String>] [-SectionIcon <String>] [-Name <String[]>] [-Title <String>] [-Width <Int32>] [-Height <Int32>] [-IncludeStandardFields]

Show-FieldEditor -Id <String> [-Database <String>] [-Language <String[]>] -PreserveSections [-Name <String[]>] [-Title <String>] [-Width <Int32>] [-Height <Int32>] [-IncludeStandardFields]

Show-FieldEditor -Id <String> [-Database <String>] [-Language <String[]>] [-SectionTitle <String>] [-SectionIcon <String>] [-Name <String[]>] [-Title <String>] [-Width <Int32>] [-Height <Int32>] [-IncludeStandardFields]

Detailed Description

Shows Field editor for a provided item allows for editing all or selected list of fields. If user closes the dialog by pressing the "OK" button "ok" string will be returned. Otherwise "cancel" will be returned.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Name <String[]>

Array of names of the fields to be edited.

This parameter supports globbing so you can simply use "" to allow editing of all fields. If a field is prefixed with a dash - this field will be excluded from the list of fields. e.g. the following will display all fields except title from Show-FieldEditor -Path "master:\content\home" -Name "", "-Title"

-Title <String>

Title of the dialog containing the field editor.

-Width <Int32>

Width of the dialog containing the field editor.

-Height <Int32>

Height of the dialog containing the field editor.

-IncludeStandardFields <SwitchParameter>

Add this parameter to add standard fields to the list that is being considered to be displayed

-Item <Item>

The item to be edited.

-Path <String>

Path to the item to be edited - additionally specify Language parameter to fetch different item language than the current user language.

-Id <String>

Id of the the item to be edited - additionally specify Language parameter to fetch different item language than the current user language.

-Database <String>

Database containing the item to be edited - can work with Language parameter to narrow the publication scope.

-Language <String[]>

Language that will be edited. If not specified the current user language will be used. Globbing/wildcard supported.

-PreserveSections <SwitchParameter>

If added this parameter tells editor to preserve the original item field sections, otherwise all fields are placed in a single section Named by SectionTitle parameter and having the SectionIcon icon.

-SectionTitle <String>

If PreserveSections is not added to parameters - this parameter provides a title for the global section all fields are placed under.

-SectionIcon <String>

If PreserveSections is not added to parameters - this parameter provides a iconfor the global section all fields are placed under.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Outputs

The output type is the type of the objects that the cmdlet emits.

  • System.String

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

Show field editor that shows all non-standard fields on sitecore/content/home item except for field "title" The dialog will be titled "My Home Item" all fields inside will be in single section.

EXAMPLE 2

Show field editor that shows all fields including standard fields on sitecore/content/home The dialog will preserve the item sections.

Related Topics

Aliases

Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases

Aliases
Aliases
Aliases
Aliases
Aliases

Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases

https://github.com/SitecorePowerShell/Console/
https://github.com/SitecorePowerShell/Console/
Receive-File
Out-Download
https://github.com/SitecorePowerShell/Console/
Add-ItemVersion
https://gist.github.com/AdamNaj/b36ea095e3668c22c07e

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

PS master:\> Show-Alert "Hello world."

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

2

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

$item = gi master:\templates

Show-Application `
    -Application "Content Editor" `
    -Parameter @{id ="$($item.ID)"; fo="$($item.ID)";la="$($item.Language.Name)"; vs="$($item.Version.Number)";sc_content="$($item.Database.Name)"} `
    -Modal -Width 1600 -Height 800
$item = gi master:\content\home

Show-Application `
    -Application "Content Editor" `
    -Parameter @{id ="$($item.ID)"; fo="$($item.ID)";la="$($item.Language.Name)"; vs="$($item.Version.Number)";sc_content="$($item.Database.Name)"} `
PS master:\> Restart-Application

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

PS master:\> Show-Input "Please provide your email" -DefaultValue "my@email.com"  -Validation "^[a-zA-Z0-9_-]+(?:\.[a-zA-Z0-9_-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$" -ErrorMessage "Not a proper email!"
PS master:\> $contentItem = get-item master:\content
PS master:\> $newName = Show-Input "Please provide the new name for the '$($contentItem.Name)' Item" -DefaultValue $contentItem.Name  -Validation "^[\w\*\$][\w\s\-\$]*(\(\d{1,}\)){0,1}$" -ErrorMessage "Invalid characters in the name"

#print new name
PS master:\> Write-Host "The new name you've chosen is '$($newName)'"
Show-Input "Please provide 5 characters at most" -MaxLength 5

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

PS master:\> Show-FieldEditor -Path master:\content\home -Name "*" , "-Title" -Title "My Home Item"
PS master:\> Get-Item "master:\content\home" | Show-FieldEditor -Name "*" -IncludeStandardFields -PreserveSections
Read-Variable
Show-Application
Show-Confirm
Show-FieldEditor
Show-Input
Show-ListView
Show-ModalDialog
Show-Result
Show-YesNoCancel
https://github.com/SitecorePowerShell/Console/
Read-Variable
Show-Alert
Show-Confirm
Show-FieldEditor
Show-Input
Show-ListView
Show-ModalDialog
Show-Result
Show-YesNoCancel
https://github.com/SitecorePowerShell/Console/
https://github.com/SitecorePowerShell/Console/
Read-Variable
Show-Alert
Show-Application
Show-Confirm
Show-FieldEditor
Show-ListView
Show-ModalDialog
Show-Result
Show-YesNoCancel
https://github.com/SitecorePowerShell/Console/
Read-Variable
Show-Alert
Show-Application
Show-Confirm
Show-Input
Show-ListView
Show-ModalDialog
Show-Result
Show-YesNoCancel
https://github.com/SitecorePowerShell/Console/

Set-ItemTemplate

Sets the item template.

Syntax

Set-ItemTemplate -Item <Item> -TemplateItem <TemplateItem> [-FieldsToCopy <Hashtable>]
Set-ItemTemplate -Item <Item> -Template <String> [-FieldsToCopy <Hashtable>]
Set-ItemTemplate -Path <String> -TemplateItem <TemplateItem> [-FieldsToCopy <Hashtable>]
Set-ItemTemplate -Path <String> -Template <String> [-FieldsToCopy <Hashtable>]
Set-ItemTemplate -Id <String> -TemplateItem <TemplateItem> [-FieldsToCopy <Hashtable>]
Set-ItemTemplate -Id <String> -Template <String> [-FieldsToCopy <Hashtable>]
Set-ItemTemplate [-Database <String>] [-FieldsToCopy <Hashtable>]

Detailed Description

The Set-ItemTemplate command sets the template for an item.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Item <Item>

The item to set the template for.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-Path <String>

Path to the item to set the template for.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Id <String>

Id of the item to set the template for.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-TemplateItem <TemplateItem>

Sitecore item representing the template.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Template <String>

Path representing the template item. This must be of the same database as the item to be altered.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-FieldsToCopy <Hashtable>

Hashtable of key value pairs mapping the old template field to a new template field.

@{"Title"="Headline";"Text"="Copy"}

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Database <String>

Database containing the item to set the template for - required if item is specified with Id.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Notes

Help Author: Adam Najmanowicz, Michael West, Alex Washtell

Examples

EXAMPLE 1

Set template of /sitecore/content/home item using a Template path.

Set-ItemTemplate -Path master:/sitecore/content/home -Template "/sitecore/templates/User Defined/Page"

EXAMPLE 2

Set template of /sitecore/content/home item using a TemplateItem.

$template = Get-ItemTemplate -Path master:\content\home\page1
Set-ItemTemplate -Path master:\content\home\page2 -TemplateItem $template

EXAMPLE 3

Set the template and remap fields to their new name.

Set-ItemTemplate -Path "master:\content\home\Page1" `
    -Template "User Defined/Target" `
    -FieldsToCopy @{Field1="Field4"; Field2="Field5"; Field3="Field6"}

Related Topics

Get-ArchiveItem

Retrieves a list of items found in the specified archive.

Syntax

Get-ArchiveItem -Archive <Archive>
Get-ArchiveItem -Archive <Archive> [-ItemId <ID>]
Get-ArchiveItem -Archive <Archive> [-Identity <AccountIdentity>]

Detailed Description

The Get-ArchiveItem command returns items found in the "archive" and "recyclebin" archives.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Archive <Archive>

Specifies the archive to use when determining which ArchiveEntry items to process. Use Get-Archive to find the appropriate archive.

Aliases

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ItemId <ID>

Specifies the ID for the original item that should be processed. This is NOT the ArchivalId.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Identity <AccountIdentity>

Specifies the user responsible for moving the item to the archive.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Inputs

None.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Sitecore.Data.Archiving.ArchiveEntry

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

The following returns all items found in the specified archive.

$database = Get-Database -Name "master"
$archiveName = "recyclebin"
$archive = Get-Archive -Database $database -Name $archiveName
Get-ArchiveItem -Archive $archive

EXAMPLE 2

The following returns items matching the ItemId found in the specified archive.

$database = Get-Database -Name "master"
$archiveName = "recyclebin"
$archive = Get-Archive -Database $database -Name $archiveName
Get-ArchiveItem -Archive $archive -ItemId "{1BB32980-66B4-4ADA-9170-10A9D3336613}"

EXAMPLE 3

The following returns items moved to the recycle bin by the user found in the specified archive.

$database = Get-Database -Name "master"
$archiveName = "recyclebin"
$archive = Get-Archive -Database $database -Name $archiveName
Get-ArchiveItem -Archive $archive -Identity "sitecore\admin"

EXAMPLE 4

The following demonstrates changing the archive date on an item followed by retrieving the archived item.

$item = Get-Item -Path "master:" -ID "{1BB32980-66B4-4ADA-9170-10A9D3336613}"
$date = $item[[Sitecore.FieldIDs]::ArchiveDate]
$serverTime = [Sitecore.DateUtil]::IsoDateToServerTimeIsoDate($date)
$serverTimeDateTime = [Sitecore.DateUtil]::IsoDateToDateTime($serverTime, [datetime]::MinValue)

# Here you could add more time to the $serverTimeDateTime

$utcTimeDateTime = [Sitecore.DateUtil]::ToUniversalTime($serverTimeDateTime)
$isoTime = [Sitecore.DateUtil]::ToIsoDate($utcTimeDateTime)

$item.Editing.BeginEdit()
$item[[Sitecore.FieldIDs]::ArchiveDate] = $isoTime
$item.Editing.EndEdit()

# Some time after the date has passed
$database = Get-Database -Name "master"
$archiveName = "archive"
$archive = Get-Archive -Database $database -Name $archiveName
Get-ArchiveItem -Archive $archive -ItemId "{1BB32980-66B4-4ADA-9170-10A9D3336613}"

Related Topics

  • Remove-ArchiveItem

  • Restore-ArchiveItem

  • Remove-Item

  • Remove-ItemVersion

Out-Download

Send an object content to the client

Syntax

Out-Download -InputObject <Object> [-ContentType <String>] [-Name <String>]

Detailed Description

The cmdlet allows to send content of an object (FileInfo, Stream, String, String[] or Byte[]) to the client. This is used for example by report scripts to send the report in HTML, Json or Excel without saving the content of the object to the disk drive. You can specify an object type and file name to make sure the downloaded file is interpreted properly by the browser.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-InputObject <Object>

Object content to be sent to the client. Object must be of one of the following types:

  • FileInfo,

  • Stream,

  • String,

  • String[],

  • Byte[]

-ContentType <String>

The MIME content type of the object. In most cases you can skip this parameter and still have the content type be deduced by the browser from the

Common examples (after Wikipedia)

  • application/json

  • application/x-www-form-urlencoded

  • application/pdf

  • application/octet-stream

  • multipart/form-data

  • text/html

  • image/png

  • image/jpg

-Name <String>

Name of the file you want the user browser to save the object as.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • System.Object

Outputs

The output type is the type of the objects that the cmdlet emits.

  • System.Boolea

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

Send first log file to the user

EXAMPLE 2

Send Hello World text file to the user

EXAMPLE 3

Get a list of sitecore branches under root item in the master database and send the list to user as excel file

Related Topics

New-ItemWorkflowEvent

Creates new entry in the history store notifying of workflow state change.

Syntax

New-ItemWorkflowEvent [-Item] <Item> [-OldState <String>] [-NewState <String>] [-Text <String>] [-Language <String[]>]

New-ItemWorkflowEvent [-Path] <String> [-OldState <String>] [-NewState <String>] [-Text <String>] [-Language <String[]>]

New-ItemWorkflowEvent -Id <String> [-Database <String>] [-OldState <String>] [-NewState <String>] [-Text <String>] [-Language <String[]>]

Detailed Description

Creates new entry in the history store notifying of workflow state change.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-OldState <String>

Id of the old state. If not provided - current item workflow state will be used.

-NewState <String>

Id of the old state. If not provided - current item workflow state will be used.

-Text <String>

Action comment.

-Language <String[]>

Language that will be used as source language. If not specified the current user language will be used. Globbing/wildcard supported.

-Item <Item>

The item to have the history event attached.

-Path <String>

Path to the item to have the history event attached - additionally specify Language parameter to fetch different item language than the current user language.

-Id <String>

Id of the the item to have the history event attached - additionally specify Language parameter to fetch different item language than the current user language.

-Database <String>

Database containing the item to have the history event attached - can work with Language parameter to narrow the publication scope.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE

Related Topics

  • Execute-Workflow

Aliases
Aliases
Aliases

Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases

Get-ItemTemplate
Add-BaseTemplate
Remove-BaseTemplate
https://github.com/SitecorePowerShell/Console/
https://github.com/SitecorePowerShell/Console/

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

true (ByPropertyName)

Accept Wildcard Characters?

false

Get-Item "$SitecoreLogFolder\*.*" | select -first 1 | Out-Download
"Hello World!" | Out-Download -Name hello-world.txt
Import-Function -Name ConvertTo-Xlsx

[byte[]]$outobject = Get-ChildItem master:\ | 
    Select-Object -Property Name, ProviderPath, Language, Varsion | 
    ConvertTo-Xlsx 

Out-Download -Name "report-$datetime.xlsx" -InputObject $outobject

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

PS master:\> New-ItemWorkflowEvent -Path master:\content\home -lanuage "en" -Text "Just leaving a note"
Send-File
Receive-File
https://github.com/SitecorePowerShell/Console/
Get-ItemWorkflowEvent
https://github.com/SitecorePowerShell/Console/

New-UsingBlock

New-UsingBlock.

Syntax

New-UsingBlock [-InputObject] <IDisposable> [-ScriptBlock] <ScriptBlock>

Detailed Description

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-InputObject <IDisposable>

Object that should be disposed after the Script block is executed.

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ScriptBlock <ScriptBlock>

Script to be executed within the "Using" context.

Aliases

Required?

true

Position?

2

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • System.IDisposable

Outputs

The output type is the type of the objects that the cmdlet emits.

  • void

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

Assuming all items under /sitecore/content/home have both 'Title' and 'MetaTitle' fields... Using New-UsingBlock to bulk update items under /sitecore/Content/ to have their 'MetaTitle' field to be equal to the 'Title' field

New-UsingBlock (New-Object Sitecore.Data.BulkUpdateContext) {
foreach ( $item in (Get-ChildItem -Path master:\Content\Home -Recurse -WithParent) ) {
        $item."MetaTitle" = $item.Title
    }
}

EXAMPLE 2

Using New-UsingBlock to perform a test with UserSwitcher - checking whether an anonymous user can change a field The test should end up showing the error as below and the Title should not be changed!

$anonymous = Get-User -Identity "extranet\Anonymous"
$testItem = Get-Item -Path master:\Content\Home

New-UsingBlock (New-Object Sitecore.Security.Accounts.UserSwitcher $anonymous) {
    $testItem.Title = "If you can see this title it means that anonymous users can change this item!"
}


New-UsingBlock : Exception setting "Title": "Exception calling "Modify" with "3" argument(s): "The current user does not have write access to this item. User: extranet\Anonymous, Item: Home ({110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9})""
At line:3 char:1
+ New-UsingBlock (New-Object Sitecore.Security.Accounts.UserSwitcher $a ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-UsingBlock], SetValueInvocationException
    + FullyQualifiedErrorId : ScriptSetValueRuntimeException,Spe.Commands.Data.NewUsingBlockCommand

Related Topics

Publish-Item

Publishes a Sitecore item.

Syntax

Publish-Item [-Item] <Item> [-Recurse] [-Target <String[]>] [-PublishMode <Unknown | Full | Incremental | SingleItem | Smart>] [-PublishRelatedItems] [-RepublishAll] [-CompareRevisions] [-FromDate <DateTime>] [-AsJob] [-Language <String[]>]

Publish-Item [-Path] <String> [-Recurse] [-Target <String[]>] [-PublishMode <Unknown | Full | Incremental | SingleItem | Smart>] [-PublishRelatedItems] [-RepublishAll] [-CompareRevisions] [-FromDate <DateTime>] [-AsJob] [-Language <String[]>]

Publish-Item -Id <String> [-Database <String>] [-Recurse] [-Target <String[]>] [-PublishMode <Unknown | Full | Incremental | SingleItem | Smart>] [-PublishRelatedItems] [-RepublishAll] [-CompareRevisions] [-FromDate <DateTime>] [-AsJob] [-Language <String[]>]

Detailed Description

The Publish-Item command publishes the Sitecore item and optionally subitems. Allowing for granular control over languages and modes of publishing.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Recurse <SwitchParameter>

Specifies that subitems should also get published with the root item.

-Target <String[]>

Specifies one or many publishing targets. The default target database is "web".

-PublishMode <PublishMode>

Specified the Publish mode. Valid values are:

  • Full

  • Incremental

  • SingleItem

  • Smart

-PublishRelatedItems <SwitchParameter>

Turns publishing of related items on. Works only on Sitecore 7.2 or newer

-RepublishAll <SwitchParameter>

Republishes all items provided to the publishing job.

-CompareRevisions <SwitchParameter>

Turns revision comparison on.

-FromDate <DateTime>

Publishes items newer than the date provided only.

-AsJob <SwitchParameter>

The Sitecore API called to perform the publish is different with this switch. You may find that events fire as expected using this.

-Language <String[]>

Language of the item that should be published. Supports globbing/wildcards. Allows for more than one language to be provided at once. e.g. "en*", "pl-pl"

-Item <Item>

-Path <String>

Path to the item that should be published - can work with Language parameter to narrow the publication scope.

-Id <String>

Id of the item that should be published - can work with Language parameter to narrow the publication scope.

-Database <String>

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Outputs

The output type is the type of the objects that the cmdlet emits.

  • None.

Notes

Help Author: Michael West, Adam Najmanowicz

Examples

EXAMPLE 1

EXAMPLE 2

EXAMPLE 3

EXAMPLE 4

Publish to many databases

Related Topics

The New-UsingBlock command disposes of the provided input object after the specified scriptblock completes execution. You may find the data returned by the scriptblock is contained within the following object System.Collections.ObjectModel.Collection1[[System.Management.Automation.PSObject, System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]`. This helps when multiple objects are returned and is .

Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases

known behavior
https://github.com/SitecorePowerShell/Console/

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

PS master:\> Publish-Item -Path master:\content\home -Target Internet
PS master:\> Get-Item -Path master:\content\home | Publish-Item -Recurse -PublishMode Incremental
PS master:\> Get-Item -Path master:\content\home | Publish-Item -Recurse -Language "en*"
PS master:\> $targets = [string[]]@('web','internet')
PS master:\> Publish-Item -Path master:\content\home -Target $targets
https://github.com/SitecorePowerShell/Console/

Invoke-Script

Executes a script from Sitecore PowerShell Extensions Script Library. This command used to be named Execute-Script - a matching alias added for compatibility with older scripts.

Syntax

Invoke-Script [-Item] <Item> [-ArgumentList <Object[]>]

Invoke-Script [-Path] <String> [-ArgumentList <Object[]>]

Detailed Description

Executes a script from Sitecore PowerShell Extensions Script Library.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Aliases

The following abbreviations are aliases for this cmdlet:

  • Execute-Script

Parameters

-Item <Item>

The script item to be executed.

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-Path <String>

Path to the script item to be executed. Path can be absolute or Relavie to Script library root. e.g. the following two commands are equivalent:

PS master:&gt; Invoke-Script 'master:\system\Modules\PowerShell\Script Library\Examples\Script Testing\Long Running Script with Progress Demo' PS master:&gt; Invoke-Script 'Examples\Script Testing\Long Running Script with Progress Demo'

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ArgumentList <Object[]>

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Outputs

The output type is the type of the objects that the cmdlet emits.

  • System.Object

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

Invoke-Script 'Examples\Script Testing\Long Running Script with Progress Demo'

EXAMPLE 2

Run a script with arguments passed in.

$scriptItem = Get-Item -Path "master:" -ID "{35311878-54EF-4E7A-9B95-3B63F5DEE97D}"

$arguments = @{
    TemplateId = "{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}"
}
$scriptItem | Invoke-Script -ArgumentList $arguments

The arguments are passed and used in the called script like below:

param($params)
$templateId = $params.templateId

Get-ItemReferrer -ID $templateId

Related Topics

Set-HostProperty

Sets the current host property.

Syntax

Set-HostProperty [-ForegroundColor <Black | DarkBlue | DarkGreen | DarkCyan | DarkRed | DarkMagenta | DarkYellow | Gray | DarkGray | Blue | Green | Cyan | Red | Magenta | Yellow | White>] [-BackgroundColor <Black | DarkBlue | DarkGreen | DarkCyan | DarkRed | DarkMagenta | DarkYellow | Gray | DarkGray | Blue | Green | Cyan | Red | Magenta | Yellow | White>] [-HostWidth <Int32>] [-Persist]

Detailed Description

Sets the current host property and perssits them for the future if used with -Persist parameter.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-ForegroundColor <ConsoleColor>

Color of the console text.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-BackgroundColor <ConsoleColor>

Color of the console background.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-HostWidth <Int32>

Width of the text buffer (texts longer than the number provided will wrap to the next line.

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Persist <SwitchParameter>

Persist the console setting provided

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

Set width of the console buffer to 80 and persist it for the future instances

PS master:\> Set-HostProperty -HostWidth 80 -Persist

EXAMPLE 2

Set color of the console text to cyan. Next instance of the console will revert to default (white).

PS master:\> Set-HostProperty -ForegroundColor Cyan

Related Topics

Show-Confirm

Shows a user a confirmation request message box.

Syntax

Show-Confirm [-Title] <String>

Detailed Description

Shows a user a confirmation request message box. Returns "yes" or "no" based on user's response. The buttons that are shown to the user are "OK" and "Cancel".

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Title <String>

Text to show the user in the dialog.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • System.String

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE

Related Topics

Reset-ItemField

Resets item fields, specified as either names, fields or template fields.

Syntax

Detailed Description

Resets item fields, specified as either names, fields or template fields.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-IncludeStandardFields <SwitchParameter>

Includes fields that are defined on "Standard template"

-Name <String[]>

Array of field names to include - supports wildcards.

-Item <Item>

The item to be analysed.

-Path <String>

Path to the item to be analysed.

-Id <String>

Id of the item to be analysed.

-Database <String>

Database containing the item to be reset - can work with Language parameter to narrow the publication scope.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Outputs

The output type is the type of the objects that the cmdlet emits.

  • None

Notes

Help Author: Adam Najmanowicz, Michael West, Alex Washtell

Examples

EXAMPLE 1

Reset all item fields, excluding standard fields.

EXAMPLE 2

Reset all item fields, including standard fields.

EXAMPLE 3

Reset all item fields with names beginning with "a", excluding standard fields.

EXAMPLE 4

The following resets one of the Standard Values fields for all versions and languages.

Related Topics

Show-ModalDialog

Shows Sitecore Sheer control as a modal dialog.

Syntax

Show-ModalDialog -Control <String> [-Parameters <Hashtable>] [-HandleParameters <Hashtable>] [-Title <String>] [-Width <Int32>] [-Height <Int32>]

Show-ModalDialog -Url <String> [-HandleParameters <Hashtable>] [-Title <String>] [-Width <Int32>] [-Height <Int32>]

Detailed Description

Shows Sitecore Sheer control as a modal dialog. If control returns a value - the value will be passed back as the result of the command execution.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Control <String>

Name of the Sitecore Sheer control to show

-Url <String>

A fully formed URL that constitutes a control execution request.

-Parameters <Hashtable>

Hashtable of parameters to pass to the control in the url.

-HandleParameters <Hashtable>

-Title <String>

Title of the control dialog.

-Width <Int32>

Width of the control dialog.

-Height <Int32>

Height of the control dialog.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Sitecore.Data.Items.Item

Outputs

The output type is the type of the objects that the cmdlet emits.

  • System.String

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE

Related Topics

Show-ListView

Sends output to an interactive table in a separate window.

Syntax

Show-ListView [-PageSize <Int32>] [-Modal] [-ActionData <Object>] [-ViewName <String>] [-ActionsInSession] [-Show <None | SharedExport | Filter | PagingAlways | SharedActions | StatusBar | All>] [-InfoTitle <String>] [-InfoDescription <String>] [-MissingDataMessage <String>] [-Icon <String>] -Data <Object> [-Property <Object[]>] [-Title <String>] [-Width <Int32>] [-Height <Int32>]

Detailed Description

The Show-ListView command sends the output from a command to a grid view window where the output is displayed in an interactive table. Because this command requires a user interface, it does not work in a non-interactive scenarios like within web service calls. You can use the following features of the table to examine your data: -- Sort. To sort the data, click a column header. Click again to toggle from ascending to descending order. -- Quick Filter. Use the "Filter" box at the top of the window to search the text in the table. You can search for text in a particular column, search for literals, and search for multiple words. -- Execute actions on selected items. To execute action on the data from Show-ListView, Ctrl+click the items you want to be included in the action and press the desired action in the "Actions" chunk in the ribbon. -- Export contents of the view in XML, CSV, Json, HTML or Excel file and download that onto the user's computer. The downloaded results will take into account current filter and order of the items.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-PageSize <Int32>

Number of results shown per page.

-Modal <SwitchParameter>

If this parameter is provided Results will show in a new window (in Sitecore 6.x up till Sitecore 7.1) or in a modal overlay (Sitecore 7.2+)

-ActionData <Object>

Additional data what will be passed to the view. All actions that are executed from that view window will have that data accessible to them as $actionData variable.

-ViewName <String>

View signature name - this can be used by action commands to determine whether to show an action or not using the Show/Enable rules.

-ActionsInSession <SwitchParameter>

If this parameter is specified actions will be executed in the same session as the one in which the command is executed.

-Show <ShowListViewFeatures>

Shows UI elements selectively in the results dialog -- All - shows all UI elements automatically - default value -- SharedExport - shows export filters that are not specific to this very -ViewName report (left-most ribbon panel) -- Filter - shows filter panel -- PagingAlways - shows paging when list is shorter than the page specified -- SharedActions - shows actions that are not specific to this very-ViewName report (right-most ribbon panel) -- StatusBar - shows status bar.

-InfoTitle <String>

Title on the panel that appears below the ribbon in the results window.

-InfoDescription <String>

Description that appears on the panel below the ribbon in the results window.

-MissingDataMessage <String>

If no Items were provided for -Data parameter the message provided in this parameter will be shown in the middle of the List View dialog to notify users of the lack of items to display.

-Icon <String>

Icon of the result window. (Shows in the top/left corner and on the Sitecore taskbar).

-Data <Object>

Data to be displayed in the view.

-Property <Object[]>

Specifies the object properties that appear in the display and the order in which they appear. Type one or more property names (separated by commas), or use a hash table to display a calculated property.

The value of the Property parameter can be a new calculated property. To create a calculated, property, use a hash table. Valid keys are: -- Name (or Label) <string> -- Expression <string> or <script block>

-Title <String>

Title of the results window.

-Width <Int32>

Width of the results window. Only applicable when also using the -Modal switch.

-Height <Int32>

Height of the results window. Only applicable when also using the -Modal switch.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • System.Management.Automation.PSObject

Outputs

The output type is the type of the objects that the cmdlet emits.

  • System.String

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE 1

This command formats information about Sitecore items in a table. The Get-ChildItem command gets objects representing the items. The pipeline operator (|) passes the object to the Show-ListView command. Show-ListView displays the objects in a table.

EXAMPLE 2

This command formats information about Sitecore items in a table. The Get-ItemReferrer command gets all references of the "Sample Item" template. The pipeline operator (|) passes the object to the Show-ListView command. Show-ListView displays the objects in a table. The Properties are not displaying straight properties but use the Name/Expression scheme to provide a nicely named values that like in the case of languages which are aggregarde form the "Languages" property.

EXAMPLE 3

The following demonstrates the use of a custom object used in the report. Notice that a custom Icon can be set.

Related Topics

  • Out-GridView

  • Format-Table

Aliases

Aliases
Aliases
Aliases
Aliases
Aliases
Aliases

Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases

Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases
Aliases

https://github.com/SitecorePowerShell/Console/
Import-Function
https://github.com/SitecorePowerShell/Console/

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

PS master:\> Show-Confirm -Title "Do you like Sitecore PowerShell Extensions?"

yes
Reset-ItemField [-Item] <Item> [-IncludeStandardFields] [-Name <String[]>]
Reset-ItemField [-Path] <String> [-IncludeStandardFields] [-Name <String[]>]
Reset-ItemField -Id <String> [-Database <String>] [-IncludeStandardFields] [-Name <String[]>]

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

PS master:\> Reset-ItemField -Path master:\content\home
PS master:\> Reset-ItemField -Path master:\content\home -IncludeStandardFields
PS master:\> Get-Item master:\content\home | Reset-ItemField -Name "a*"
Get-ChildItem -Path "master:" -ID "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}" -Version * -Language * -Recurse |
    Reset-ItemField -Name "__Workflow State" -IncludeStandardFields

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

PS master:\> 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 400

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

true

Position?

named

Default Value

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

PS master:\> Get-Item -path master:\* | Show-ListView -Property Name, DisplayName, ProviderPath, TemplateName, Language
PS master:\> Get-ItemReferrer -path 'master:\templates\Sample\Sample Item' | 
                 Show-ListView -Property `
                     @{Label="Name"; Expression={$_.DisplayName} }, 
                     @{Label="Path"; Expression={$_.Paths.Path} }, 
                     @{Label="Languages"; Expression={$_.Languages | % { $_.Name + ", "} } }
$item = Get-Item -Path "master:\content\home\sample item 1"
 
$customItem = [pscustomobject]@{
    "ID"=$Item.ID
    "Icon"=$Item.__Icon
    "DisplayName"=$Item.DisplayName
    "ItemPath"=$Item.ItemPath
    "Version"=$Item.Version
    "Language"=$Item.Language
    "__Updated"=$Item.__Updated
    "__Updated by"=$Item."__Updated by"
}

$customItem | Show-ListView
Read-Variable
Show-Alert
Show-Application
Show-FieldEditor
Show-Input
Show-ListView
Show-ModalDialog
Show-Result
Show-YesNoCancel
https://github.com/SitecorePowerShell/Console/
Get-ItemTemplate
Get-ItemField
https://github.com/SitecorePowerShell/Console/
Read-Variable
Show-Alert
Show-Application
Show-Confirm
Show-FieldEditor
Show-Input
Show-ListView
Show-Result
Show-YesNoCancel
https://github.com/SitecorePowerShell/Console/
Update-ListView
Read-Variable
Show-Alert
Show-Application
Show-Confirm
Show-FieldEditor
Show-Input
Show-ModalDialog
Show-Result
Show-YesNoCancel
https://blog.najmanowicz.com/2014/10/25/creating-beautiful-sitecore-reports-easily-with-powershell-extensions/
https://michaellwest.blogspot.com/2014/04/reports-with-sitecore-powershell.html
https://sitecorejunkie.com/2014/05/28/create-a-custom-report-in-sitecore-powershell-extensions/
https://github.com/SitecorePowerShell/Console/
Sitecore PowerShell Extensions
The Sitecore PowerShell Console is a command line interface that many power users find great for quickly running commands.
The Sitecore PowerShell ISE is a scripting interface for running commands and authoring scripts.
Host output using Show-Result
Accessing the report
Paged results of commands
Highlight the command and press Ctrl + Enter
A help dialog for Get-Rendering
PowerShell ISE
ISE Settings Tab
ISE Plugins Tab
Open Script Dialog
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
PowerShell Console
Ribbon Script Library Structure
Small and Combo Buttons
Buttons in the Ribbon
License Expiration Warning
Module Creation
Shared Functions Library
Autocomplete in ISE
A Notification for the current date
An Experience Button for sending emails
Message Input
Email Response
Item Added Event Handler
PowerShell Script Command
PowerShell Script Task
Insert Option for Task
Run or Edit Task Schedule
Dialog to Select Task Scripts
Dialog to Edit Task Schedule
Reports
Unused Media Items
Unused Media Items Output
Reports without Access
Report Viewer Access
Reports with Access
Scheduled Task Menu
Edit Scheduled Task
Droplink query
Elevate Session State
Elevate session
Drop session
Elevated session state required
Drop elevated session state
Choose report index
Filter report results
Final results
Show Full Info
Actions seen for scheduled task items
Rules configuration for actions
Action script
Save action script
Open rules editor for report
Add rules for report
Now the List Children action is available
Now the action is unavailable
Updating report content
Show progress of long running actions
Invoke JavaScript
Example 3
Publishing Status
Insert Scheduled Task
New Module
Integration Points
Integration Point Libraries
Module Activation
Package Generator
Module Toolbox Library
Module Libraries
ISE Edit
ISE Settings Tab
Libary Script