Visualize PowerShell Verbs

Visualizing data is fun. I came across the Brunel Visualization project and figured I’d kick the tires.

I created a dataset (csv file) containing the count verbs in my PowerShell session. Then I pointed Brunel Visualization tool at that csv and created a bubble chart.

Click the image below to render the interactive chart.
Note: It takes a bit of time for the Brunel website to import and render.


PowerShell to Generate the Dataset

New PowerShell DSC Resource Provider

I created a new PowerShell DSC (Desired State Configuration) Provider that compiles Elm Language files.

Elm is a functional programming language in your browser.

If you’re running PowerShell v5.0? It’s on the PowerShellGallery.
From the prompt PS C:\>Install-Module -Name ElmDSCResource

The source is up on GitHub HERE.

I built an interactive Buzzword Bingo page.


Using PowerShell to create Excel Spreadsheets without having Excel installed

This module makes working with Excel from PowerShell a breeze (plus, you don’t need Excel installed, great for server side spreadsheet creation).

Super simple, creates an Excel spreadsheet with all the process running on your box and the related data details.
Get-Process | Export-Excel -Path test.xlsx -Show

I added Conditional Formatting, check out the How To video:


Get the PowerShell Module

On GitHub and the PowerShell Gallery

PowerShell Enum and the Three Stooges

The Enum

PowerShell v5.0 comes with a new keyword, enum. An enum is a distinct type that consists of a set of named constants called the enumerator list.

Here, there are two constants, None and Sort. There can be many more.

The Update Function

When specifying parameters in a function, it is easier to constrain the parameter to a valid list so that the user cannot accidentally pass an invalid information. Casting the $action parameter to the [Action] enum lets PowerShell handle invalid input, saving you time from writing error handling code.

Plus, now that $action is of type [Action], you and your users can benefit from intellisense. You don’t need to look up the values, and tab completion works.

In Action

Setup up a list of names:

Now lets call update with an an invalid action.

PowerShell throws a nicely detailed error, even telling you what are valid values for the action parameter. This approach makes your scripting more bullet proof and cuts down emails with questions. All you need to do is create an enum and cast your parameters.

update : Cannot process argument transformation on parameter 'action'. Cannot convert value "BadAction" to type "Action". Error: "Unable to match the identifier name BadAction to a valid enumerator name. Specify one of the following enumerator names and try again: None, Sort"
At line:1 char:8
+ update BadAction $names
+ ~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [update], ParameterBindingArgumentTransformationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,update

Calling the update function with the valid Sort option, returns the sorted list of names.

The Full PowerShell Script