Simple PowerShell based deployments
PSDeploy is a quick and dirty module to simplify PowerShell based deployments.
The idea is that you write a *.psdeploy.ps1 deployment configuration with sources and targets, and PSDeploy will deploy these.
Suggestions, pull requests, and other contributions would be more than welcome! See the contributing guidlines for more info.
Invoking PSDeploy is very similar to running Invoke-Pester. Here's an example, Some.PSDeploy.ps1
Deploy ActiveDirectory1 { # Deployment name. This needs to be unique. Call it whatever you want
By Filesystem { # Deployment type. See Get-PSDeploymentType
FromSource 'Tasks\AD\Some-ADScript.ps1', # One or more sources to deploy. Absolute, or relative to deployment.yml parent
'Tasks\AllOfThisDirectory'
To '\\contoso.org\share$\Tasks' # One or more destinations to deploy the sources to
Tagged Prod # One or more tags you can use to restrict deployments or queries
WithOptions @{
Mirror = $True # If the source is a folder, triggers robocopy purge. Danger
}
}
}
Let's pretend Some.PSDeploy.ps1 lives in C:\Git\Misc\Deployments. Here's what happens when we invoke a deployment:
Invoke-PSDeploy -Path C:\Git\Misc
# One time setup
# Download the repository
# Unblock the zip
# Extract the PSDeploy folder to a module path (e.g. $env:USERPROFILE\Documents\WindowsPowerShell\Modules\)
#Simple alternative, if you have PowerShell 5, or the PowerShellGet module:
Install-Module PSDeploy
# Import the module.
Import-Module PSDeploy # Alternatively, Import-Module \\Path\To\PSDeploy
# Get commands in the module
Get-Command -Module PSDeploy
# Get help for the module and a command
Get-Help about_PSDeploy
Get-Help Invoke-PSDeploy -full
The PSDeploy docs will include more information, including:
The blog posts (one, two), and three will become out of date over time, but may include helpful details
Thanks go to: