Tag Archives: Plaster

No Prompt Plaster

I took a few hours last week and familiarized myself with Plaster. And no, not the walls and ceiling home improvement project Plaster — Microsoft’s Plaster. The one that requires you search for it alongside the search term PowerShell, otherwise you’ll never get close to what I’m going to briefly discuss.

Plaster allows you to create the folders and files needed for a project, in a repeatable way in order that… well… you don’t have to do it manually. I never quite enjoyed the manual process of most things PowerShell, but especially the process of creating PowerShell script modules: create a folder, rename it, create a .psm1, rename it, create a… Why should I create all the necessary folders and files, if an automated process can do it for me? That’s what this is all about — saving seconds. They add up.

For every video I watched, and post I read, I couldn’t seem to find what I wanted. You see, Plaster by default will prompt you the information needed to create your project. That’s nice and all, and especially because it prompts for the information I’ve determined I need, but how does one run this in an automated fashion already? No one blogged on that (that I read originally), and that’s why we’re here today.

In reading about the Plaster project on GitHub, I read this: “Or you could provide all the required template parameters as dynamic parameters and not be prompted for any of them.” Say what!?

I just knew it had to exist, and there it was — in bold even, in just the right place. For those concerned, I would’ve eventually read the help in full. It’s just what I found first. Honestly though, what I expected to find first was a mention of this in the blog posts and videos I chose to read, and watch. I should note that Mike F. Robbins does mention it here: http://mikefrobbins.com/2018/02/15/using-plaster-to-create-a-powershell-script-module-template. I’d hadn’t quite gotten to that post, as I wondered why I hadn’t found my answer in the first few things I inspected. Do read the link if you have an interest, as Mike includes a full Plaster introduction.

Just in case someone does what I did there for a moment, you don’t have to use Plaster in a manual, you’re-going-to-get-prompted-for-everything manner. Instead, you can do something like the below example, where you provide values to the Plaster parameters you’ve included. Do notice, as Mike mentions, that there’s no tab completion on these parameters. Annoying, but worth it for the automated aspect of Plaster.

Invoke-Plaster -TemplatePath $PSScriptRoot\Tests\TemplateRoot1 -DestinationPath $PSScriptRoot\Tests\Out -ModuleName CoolModule -Version 2.1.1 -License MIT -Options Pester,PSake,Git