Tuesday, January 28, 2014

Publish a page from PowerShell

Today I fiddled around with PowerShell and found you can pretty easily publish a page in SDL Tridion. This can come in handy for administrative tasks where you typically want to automate in scripting, to avoid to setting up a .NET console project with a lot of code to maintain.

The Tridion PowerShell Modules project comes in handy to get you a CoreService client. It's just five steps to install this module on your machine.
  1. Get the .psm1, .psd1 and DLL files from the project.
    You can also copy the CoreService DLL from the %TRIDION_HOME%bin\client\CoreService folder on your own Content Manager server if you do not like to download the DLLs from the project.
  2. Create a directory
    C:\Users\your_username\Documents\WindowsPowerShell\Modules\Tridion-CoreService
  3. Copy the .psm1, .psd1 and .dll files in that directory
  4. Restart any open PowerShell consoles or run Import-Module Tridion-CoreService in the open PowerShell console.
Once you can use the PowerShell module, run a simple script to publish the page.


Also see http://tridion.stackexchange.com/questions/4331/how-can-i-publish-a-page-by-using-powershell

As an example administrative task, take this question. For unclear reasons we need to publish a page every hour or so. This is not a Tridion best practice, but easy to automate. Just have a Windows Scheduled Task which runs powershell -file "C:\publish-a-page.ps1". That will do the trick effectively.

For future optimization: you could extend the Tridion PowerShell Modules to help you to perform this simple publishing action without setting up the PublishInstruction and ReadOptions and all.

Friday, January 3, 2014

Showing errors in a ECL mountpoint

External Content Library (ECL) Providers can raise error messages in a very user friendly way. The mountpoint can show a list item with the error message when it occurs and error and cannot get data from the external system. This avoids confusing the Tridion CME user with an error message in a popup and having an empty list.


This idea came up in a Tridion.Stackexhange Q&A on http://tridion.stackexchange.com/questions/3097/raising-an-error-from-a-ecl-provider

The solution is implemented in the Flickr ECL provider. See this commit to discover
how this works in more detail.

Basically the Flickr mountpoint will return a error message in a IContentLibraryListItem which represents the error. This ErrorListItem object will have it's own DisplayTypeId so that it can show error icons.

Tridion Core Service in PowerShell

The tridion-powershell-modules project is a PowerShell module written by Peter Kjaer which allows easy access to the Tridion Core Service through PowerShell. Windows PowerShell allows to use the CoreService client DLL and allows to create simple scripts to do Tridion CM maintainance.

This module introduces a number of Powershell commands like Get-TridionClient and Get-TridionUser to interact with the CoreService. Setup for Tridion 2011, 2013 or 2013 SP1 is super easy with the Set-TridionCoreServiceSettings command.

Find the module and the source code in http://code.google.com/p/tridion-powershell-modules/

Earlier I posted a Tridion.Stackexchange answer on how to install and configure the module in Windows Powershell http://tridion.stackexchange.com/a/3643/88

I use a little PowerShell script to remove and install the module when Peter releases a new version https://gist.github.com/jhorsman/7658365


tip #1

Make sure you put the module files in a directory named "Tridion-CoreService". A previous version required a directory names "CoreService" but the module is renamed. If the folder name and module name don't match you will get errors like "Import-Module : The specified module 'CoreService' was not loaded because no valid module file was found in any module".


tip #2

Run Get-Command -Module Tridion-CoreService to learn about the other command in the module.