Powershell: The many ways to use regex

Regular expressions (regex) match and parse text. The regex language is a powerful shorthand for describing patterns. Powershell makes use of regular expressions in several ways. Sometimes it is easy to forget that these commands are using regex becuase it is so tightly integrated. You may already be using some of these commands and not even realize it.


Image from xkcd.com, slightly altered

[Read More]

Powershell: Building a Module, one microstep at a time

I am really quick to build a module out of my scripts and functions. I like how it allows me to organize my functions and use them in other scripts. I also see that many PowerShell scripters are slow to take that step of building a module. We often learn how to build a module without really understanding why they are built that way.

In this post, we will turn a common script scenario into a full module one step at a time. We will take several microsteps to show all the subtle details of why common modules are built the way they are. Lets take the mystery out of building a module to see how simple they can be.

[Read More]

Powershell: Writing an alternate TypeExtension DSL, DSLs part 5

In my last post on DSLs, I broke down a proposed DSL that someone else had described. It was drafted specifically as an example DSL for a RFC. Today, I am going to propose an alternate DSL syntax and I am going to break down the implementation just like I did last time.

My real motivation for this is to break away from the way most DSLs are implemented. There is a strong tenancy to see every keyword as an advanced function that takes a string and a script block. I want to show that we have other options.

[Read More]

Powershell: GetPlastered, a Plaster template to create a Plaster template

I recently started working with Plaster and I really like this module. I covered my first template in my Adventures in Plaster blog post last week. I have been pulling together ideas for more Plaster templates and I thought up a fun one to work on.

I am going to build a Plaster template that builds a Plaster template. I am calling this new template GetPlastered.

This will be a good example demonstrating the TemplateFile features of Plaster.

[Read More]

Powershell: Adventures in Plaster

David Christian recently wrote an article about how to use Plaster on OverPoweredShell.com. If you are new to Plaster, I pulled this from the Plaster readme.

Plaster is a template-based file and project generator written in PowerShell. Its purpose is to streamline the creation of PowerShell module projects, Pester tests, DSC configurations, and more. File generation is performed using crafted templates which allow the user to fill in details and choose from options to get their desired output.” -The Plaster readme.md

[Read More]

Powershell: PSGraph the Get-Help related links

I saw this tweet by Glenn Sarti where he was building a graph database of the PowerShell help system as a way to demonstrate Neo4j.

I thought it was a cool idea and I was curious what I could do with my PSGraph module on that same dataset. I am pulling examples right from Glenn Sarti’s article because he did a great job explaining it.

[Read More]

Powershell: Writing a TypeExtension DSL, DSLs part 4

Steffen Stranger pointed the PowerShell-RFC RFC0017-Domain-Specific-Language-Specifications out to me recently.

The RFC is about making it easier to implement a DSL in Powershell with C#. They have an example of a DSL to replace types.ps1xml. It is a nice clear example of a DSL.

[Read More]

Powershell: What have you done this month? April 2017

Here is a breakdown of all the posts and other Powershell projects that I worked on this month.

Personal/Community efforts

These are the projects and idea that I do on my own time for the community. Most of my personal projects are published on this blog or as a contribution on GitHub.

[Read More]
Tags: Monthly

Powershell: Advanced Gherkin features in Pester 4.0

In the last post, I covered the bare basics of how to use Gherkin. I had a conversation with Joel Bennett on twitter about Gherkin and he pointed out some more examples from his Configuration module. Now that I have been playing with them for a few days, I decided it was time to share my findings.

This is the 2nd post in a 3 part series on Gherkin where I cover the advanced features. These features are the building blocks that give Gherkin a lot of power.

[Read More]

All .Net Exceptions List

When I am creating error messages in PowerShell scripts, I like to use common .Net exceptions. Most of the time when I am searching for a list of exceptions to use, I end up using the All .Net Exceptions list generated by Mike Vallotton. I thought it was a clever idea so I went ahead and generated an updated list of my own.

I did this by parsing all the .Net 4.6.1 Namespace xml files on my system. All of the content below is auto generated and comes from Microsoft’s files that are used for IntelliSense. I hope you find this list of .Net Exceptions as useful as I do.

[Read More]