My PowerShell Scripting Setup

Posted by:

|

On:

|

A comfortable environment can help increase productivity, code quality, and can also make learning new information much more enjoyable. With that being said, I’m here to breakdown what I currently use to make my day-to-day PowerShell scripting tasks most comfortable for me in hopes it will also help you experiment with what works best for you.

It’s important to note that Microsoft has Windows PowerShell ISE which many may be aware of. Some may still be using this application to develop PowerShell scripts but please note that ISE is deprecated. We will be focusing on Visual Studio Code in this article.

Visual Studio Code is a code editor developed by Microsoft that supports many programming languages, extensions, themes, etc. If you are not already using VSC, I highly recommend that you download the latest version from Microsoft here: Visual Studio Code – Code Editing. Redefined

Visual Studio Code Configuration

My VSC set up is pretty bare-bones, but there are two absolute must haves for me working with PowerShell daily:

  • The official PowerShell Extension from Microsoft
  • A quality dark / night visual theme

Microsoft offers an official PowerShell extension for VSC. The extension offers syntax highlighting, code snippets, and problems reported by PowerShell Script Analyzer (for more information tied to PSScriptAnalyzer please visit the GitHub page here: GitHub – PowerShell/PSScriptAnalyzer: Download ScriptAnalyzer from PowerShellGallery). Installing the extension is very easy, you can find it with a quick search of “PowerShell” in the extension section of VSC:

Now for a quick example as to why I really enjoy this extension; in the below example, you can see that this is a test script with no detected problems.

Then after we enable the extension and review the reported problems again, we can see that the extension has found two problems that need to be corrected in the script. Clicking the problems will also bring you to the line that requires correction.

While it should be noted that the extension/analyzer won’t necessarily pick up all problems, it helps to ensure that best practices are followed.

The second necessity for me is a quality night / dark theme that’s easy on the eyes. Currently I use the Night Owl theme by Sarah Drasner:

After trying a lot of darker themes, this by far has been my favorite that I always come back to. With as beautiful as it is, what’s not to love!

Screenshot of the theme active along with the PowerShell extension:

Well, that’s the setup! It’s pretty simple but I think it’s best to keep it that way. For an added comfort bonus I recommend getting a great quality keyboard that feels good for you. Happy scripting!