Fork me on GitHub

Introduction

psDeploy contains both a library of cmdlets and a simple framework to drive deployments, which can either be used independently or together. The framework helps writing terse deployment scripts by automating common aspects such as logging and error handling.

Simple template

Here is a simple template which illustrates a simple deployment script using psDeploy:

Set-StrictMode -Version 2
$ErrorActionPreference = 'Stop' 

Import-Module psDeploy

$psDeploy.Log.Name = 'Example2'
$psDeploy.Log.Journal = 'C:\Logs\Journal.txt'
$psDeploy.Log.Transcripts = 'C:\Logs\Transcripts'

deploy -transcript -journal -script {

    Write-Host "Doing stuff..."

} -success {
    
    Write-Host "Let's start testing"

} -failure {

    Write-Host "Please check the logs"

}
				

This template illustrates the following common practices:

Driving the deployments

Whether deploying from a local desktop, the CI server or any other machine, Powershell scripts usually need to be triggered externally.
A common way to do this is to call them from a DOS batch file, or from something similar to the ANT <exec> task.

It is recommended to call powershell the following way:

powershell.exe -NoProfile -ExecutionPolicy Unrestricted -File .\deploy.ps1
				
This has the following advantages: