November 7, 2018

ChatOps - Part 2

For the first post demonstrating our use of PoshBot, I'm going to showcase a part of the main function we wrote as a PowerShell module to deploy packages using PDQ Deploy. It's really simple, and really powerful!

function deploy {

[cmdletbinding()]
[PoshBot.BotCommand(
    CommandName = 'deploy',
    Aliases = ('push'),
    Permissions = 'run'
)]
param(
    [Parameter(Position=0)][string]$package,
    [Parameter(Position=1)][string]$target,
)

$pkgpush = pdqdeploy deploy -Package $package -Targets $target | Format-List | Out-String -Width '80'

New-PoshBotCardResponse -Type Normal -Text $pkgpush

PoshBot lives on the server we run as our PDQ Central Server, which allows it to take advantage of the service account that PDQ Deploy uses ("pdq" - really inventive username) to perform various PowerShell and shell-based tasks.

Credit to Kyle Levenick for help coding & testing the script.