Month: March 2017

VS Code + Integrated Console + Pester = No Excuse Testing

Following up on an earlier post where I lightly touch on using the PowerShell Extension for the VS Code editor, I’d love to share how easy it is to Pester test and hopefully convince you to start testing your code today! If you’re not familiar with me, I’m a huge fan of Pester. I mean this is such a great module that it’s baked into Windows! I Pester test EVERYTHING. Even things outside of my custom PowerShell functions… ETL executions, Jenkins job statuses, all kinds of things. I did a post about Pester testing SQL Server stuff, check it out if you haven’t seen it!

Using VS Code and the PowerShell extension, writing Pester tests has never been easier!!

(more…)

Advertisements

Using the PowerShell Integrated Console in VS Code

VS Code is my absolute favorite editor. It has been my GoTo IDE for Chef cookbook development for some time. I was hooked when I tried the PowerShell Extension as my default terminal (ctrl + `) and saw my profile stuff (err – PSReadLine) all loaded up:

terminal_profile_awesome

Then to try out the 0.10.0 release. Wow, completely blown away! We now have a fully integrated console to run and debug PowerShell scripts. Many thanks to  David Wilson and Keith Hill for this awesome stuff.

Let’s take a look at the integrated console.

interactive_console

Just like PowerShell ISE, I can highlight a hash table and the shortcut for “Run Selection” (F8) and jump down to the console to check the variable values. This is really useful for stepping thru some code or building out new code.

All of the commands I’ve tried so far seem to work nicely. This will for sure replace PowerShell ISE for me.

$settings = @{
  hashkey = 'value'
}

(0..100) | 
  Get-Random -Count 10 | 
    %{ Write-Output "Hello, this is $_ reporting..." }