Parameter Validation Using Pester

Rob Sewell is using Pester to write Powershell unit tests and wants to test the existence of a parameter:

Here is the start of the function. I validate the VMName parameter to ensure that there a VM with that  name does not already exist

Before Rob’s posts, I hadn’t seen Pester before, but if you write a lot of Powershell code, it looks like a nice testing framework.

Related Posts

Collecting PRINT Outputs From Powershell

Jana Sattainathan shows how to query a number of SQL Server instances in parallel using Powershell and collecting the PRINT outputs from each: As an example, you may have a block of SQL that PRINTs out the current privileges in the databasethat can then be saved off and used as an independent script. In my case […]

Read More

Quantifier {x,y} Following Nothing

Shane O’Neill reminds us that reading is fundamental: Glancing at the error message, the first things that stick out are the bits “{x,y}” so I change my regex to be anywhere from 1 to  digits "*\d{1,6}$" Why are you glancing, read the error message! That doesn’t work, so I again quickly scan the error message and see the bit […]

Read More


February 2016
« Jan Mar »