Shotgun Powershell Module

Published on Tuesday, 9 May 2017

Shotgun Module

This is a simple module which makes running the same set of tasks over and over again as simple as pressing the enter key. The idea is to help developers (and sysadmins) stay in the zone when coding and reduce the friction to complete a task.

How to install:

Run the following from an elevated powershell console.

install-module shotgun

Example 1: Copying data to usb sticks.

Say you have 20 usb sticks that you need to copy a bunch of files on to.

You could write a script that does this by writing the following:

shotgun { Copy-Item c:\usbfiles d:\ -Force -Recursive }

Now when you run this it will prompt you to press enter to run the task again until you tell it to exit. This will give you the chance to change the usb stick over.

Example 2: Run complex build script.

Say you have to run your code on a remote development server to run it while you are developing it.

shotgun { .\build.ps1 -target Test -server devfooserver }

Now it will allow the developer to run the above command over and over by just pressing enter.

Example 3: Multiple Actions

The module also allows you to create multiple actions to select from by creating a shotgun.psd1 file.

Example shotgun.psd1 file:

@{
    Action1 = {
        Write-Host "Action 1 ran"
    }

    Action2 = {
        Write-Host "Action 2 ran"
    }

    Action3 = {
        Write-Host "Action 3 ran"
    }
} 

Now when you run just shotgun it will prompt you for any of the actions above and also let you run the last run action again by just pressing enter.

Source Code:

https://github.com/wiltaylor/shotgun

License: MIT