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.

No comments:

Post a Comment