Scripting ALL the things!

with Sitecore Powershell Extensions

Very briefly about me

Alex Washtell

srs bsns:
@kasaku_dev

lol jk:
@awashtell

Sitecore
Powershell Extensions

Brings the flexibility and productivity of Powershell into Sitecore

Available as a marketplace module

In development since 2012, now on version 3.3

Open source. Contributions welcome.

REALLY good. I mean, like, for reals.

Key development
contributors

Adam Najmanowicz
@adamnaj

Michael West
@michaelwest101

Why use SPE?

Have you ever needed to execute a task in Sitecore such as:

  • Making a "small" change across a large number of items
  • Bulk renaming or moving items
  • Removing items that are no longer referenced
  • Producing a report of the oldest pages in the site
  • ... in Excel format?

How are you executing these tasks
in your Sitecore environments?

Is it via ASPX pages, tucked away in an admin folder?

Don't worry, we've all done it.

Perhaps via C# code,
but integrated into the Sitecore shell?

Better, but still requires boilerplate code
and a deployment

With SPE:

Create and manage tasks as Powershell
scripts, held in Sitecore items

Alongside an environment for executing them

With full Sitecore API and shell integration support

Accelerated delivery.

Reduced deployments.

Happy developer.

Powershell 101

Command-line shell and scripting language built on the .NET Framework

First released in 2009

Now pre-installed in all versions of Windows
and a core part of the OS.

Cmdlets


Set-Location C:\My\Folder
                            

Get-ChildItem                                
                            
                      
Copy-Item MyFile.Txt -Destination c:\My\OtherFolder
                            

Pipelines


Get-ChildItem C:\My\Folder | Copy-Item -Destination c:\My\OtherFolder
                            

Get-ChildItem | 
    Where-Object { $_.LastWriteTime -lt (Get-Date).AddMonths(-1) } | 
    Sort-Object LastWriteTime
                            

Aliases


Get-ChildItem | 
    Where-Object { $_.LastWriteTime -lt (Get-Date).AddMonths(-1) } | 
    Sort-Object LastWriteTime
                            

gci | ? { $_.LastWriteTime -lt (Get-Date).AddMonths(-1) } | sort LastWriteTime
                            

Lots of other lovely stuff

  • Functions
  • Remoting
  • Background jobs
  • Modules
  • Supplied with ISE
  • Debugging

Hosting

The Powershell runtime can be hosted
by any managed application.

Allows the Sitecore integration magic

Demos already, jeez.

Integration Points

Content Editor

- Context Menu

- Gutter

- Insert Item

- Ribbon

- Warning

 

Control Panel

Event Handlers

List View Actions

Page Editor Notifications

 

Logged In Pipeline

Logout Pipeline

Start Menu Reports

Toolbox

Web API

This is AMAZING!

Now where do I get it?

Module

http://bit.ly/scpowershell

Search: sitecore powershell

Manual

http://bit.ly/scpshelp

Search: sitecore powershell gitbook

Sitecore Slack Group

http://sitecorechat.slack.com

Channel: #module-SPE

Contributing

Absolutely welcome!

Gitbook includes full guide on how to
get the dev environment running

Join the Slack channel to collaborate

Thanks!

@awashtell