After building up Pester tests for numerous things (SQL Server Build checks, compliance checks, the list goes on!). The next step was to load them into Jenkins and parameterize them so we can run them against any server we like, pass in credentials etc. After that, you can of course publish them in the Jenkins job via the NUnit plugin. so you get to look at something like the below:


This is good as long as your happy looking at all your results in Jenkins. If how ever you want to load your pester tests into say a database be it SQL Server or anything (We use ElasticSearch for our central hub of analytics) you need to do some tweaking! After looking on Google for solutions and trying a few Slack channels I came up with nothing 😦 So decided to have a morning tinkering with the XML output and see what i could make. To be honest i expected the worst as the last time i looked at XML it was in T-SQL and well that’s just not fun for anyone (plan cache / XE anyone!?)! To my surprise it was actually quiet simple to parse out in PowerShell.. So simple in fact I created a function to do it. You pass in the output file of your Pester test and you get a lovely pscustomobject as output.  This means you can send the results anywhere you like. If your thinking of SQL Server, Id go with DBATools Write-DbaDataTable. For me, pushing to Elastic i have another function that i may publish another day. Below is an example of using the function:

Example Usage

Output of Parse-PesterXML


Pester Results in SQL Server


As you can see in the above example. I ran a Pester test with output to OSreport.xml using the NUnitXML format.  Then i just used the output file in my function to get a simple result set of the test.

I’m quiet excited by this one as it’s going to be great pushing more data to ElasticSearch and keeping things centralized and view-able to a wider group than those that can run the tests.

If you are interested in the function you can find it on Github here: