PowerShell Pro Tools provides a complete PowerShell development toolset for Visual Studio, Visual Studio Code, or standalone PowerShell sessions.

Timothy Warner

Timothy Warner is a Microsoft Cloud and Datacenter Management Most Valuable Professional (MVP) who is based in Nashville, TN. Check out his Azure and Windows Server video training at Pluralsight, and feel free to reach out to Tim via Twitter.

Latest posts by Timothy Warner (see all)

Microsoft Most Valuable Professional (MVP) Adam Driscoll is one of my PowerShell heroes for the following reasons:

  • He is a brilliant software developer.
  • He gives freely to the Microsoft technology community.
  • He is an astute businessman.

In 2010 Adam created PowerGUI VSX, a free Visual Studio add-on that gave Visual Studio its first PowerShell language support. Fast-forward to 2019, and alongside much critical acclaim, Adam's product portfolio has broadened to include:

As a PowerShell administrative scripter, you may be thinking, "Why should I care about Visual Studio?" In response I want to remind you that Visual Studio (a) is available in a free Community Edition and (b) offers us a first-class PowerShell development experience when you use Adam's tools.

Installing PowerShell Pro Tools ^

In Visual Studio, open the Extensions menu and select Manage Extensions. As shown in the following screenshot, you'll find Adam's PowerShell Tools for Visual Studio in the Visual Studio Marketplace.

Installing PowerShell Pro Tools in Visual Studio 2019

Installing PowerShell Pro Tools in Visual Studio 2019

The PowerShell Pro Tools are bundled with the PowerShell Tools extension; you needn't install anything else. All functionality is unlocked for three weeks, after which you must purchase a license if you want to continue using the Pro Tools.

An important point: The PowerShell Tools for Visual Studio extension is free; look at the feature comparison to spot the differences. In a nutshell, the free extension gives you your basic PowerShell language support, including:

  • Syntax highlighting
  • IntelliSense
  • PSScriptAnalyzer integration
  • Snippets
  • Local and remote debugging

As you'll learn momentarily, PowerShell Pro Tools extends on the basic extension's functionality by providing:

  • C# to PowerShell code conversion
  • Build events and package bundling
  • Code obfuscation
  • WinForm and Windows Presentation Foundation (WPF) designers

To license PowerShell Pro Tools in Visual Studio, click Help > About PowerShell Pro Tools and enter your product key.

Only PowerShell Pro Tools (the paid product) is available for Visual Studio Code. Locate the extension in the Visual Studio Marketplace, as shown in the next figure.

Installing PowerShell Pro Tools in Visual Studio Code

Installing PowerShell Pro Tools in Visual Studio Code

To license PowerShell Pro Tools in VSCode, open the command palette, type PowerShell Pro Tools: Install License Key, paste in your key, and away you go!

Finally, install PowerShell Pro Tools as an ordinary module by running the following PowerShellGet command:

And then run the following command to install your license:

Okay, enough with the preliminaries—let's test out this extension! In the interest of time and whitespace, I will use Visual Studio 2019 as my testing environment from now on.

Configuring PowerShell Pro Tools ^

Your first stop in Visual Studio is to open Tools > Options, navigate to PowerShell Tools > General, and set your extension preferences. In particular, here is where you can optionally disable the PSScriptAnalyzer integration if it annoys you or otherwise gives you trouble.

Next, in the Options dialog, navigate to Environment > Fonts and Colors and optionally customize the syntax highlighting for the many PowerShell options. You can see this interface in the next screenshot.

Setting PowerShell custom code colors

Setting PowerShell custom code colors

Writing and running PowerShell code ^

When you install PowerShell Tools for Visual Studio, you can create PowerShell modules or script projects by using the included templates. Here, let me show you the New Project dialog in Visual Studio 2019:

Creating a new PowerShell project in Visual Studio 2019

Click View > Other Windows > PowerShell Interactive Window to open a Visual Studio-anchored PowerShell console host. Pretty cool!

Check out the next figure to observe that PowerShell Tools for Visual Studio gives us syntax highlighting and IntelliSense for PowerShell just like we'd expect for C#:

IntelliSense for PowerShell

IntelliSense for PowerShell

As far as running your code is concerned, you can use the standard Visual Studio run and debug commands (F5, Ctrl+F5, and so on). You can always right-click selected code and choose Run Selected Code from the shortcut menu to run just that line in the PowerShell Interactive window.

Finally, PowerShell Pro Tools gives you some excellent project item templates, including:

  • PowerShell script
  • PowerShell test
  • PowerShell script data file
  • PowerShell WPF window
  • PowerShell script module
  • PowerShell form
  • PowerShell service

Next let's examine a few of the PowerShell Pro Tools-only product features.

Performing code conversions ^

The PowerShell Pro Tools code conversion feature serves developers who need to refactor their existing C# code to PowerShell or vice versa. Here's how you use it:

  • In your original source file, copy your C# or PowerShell source code to the clipboard.
  • In your target file, right-click and choose either Paste as PowerShell or Paste as C# from the shortcut menu.

Here's what the simple "Hello world" C#-to-PowerShell process looks like on my system:

C# to PowerShell code conversion

C# to PowerShell code conversion

I imagine that for some businesses, the code conversion feature alone is enough to justify the license cost.

User interface design ^

Although the idea of writing a graphical PowerShell application may seem illogical to you at first blush, it really isn't. For example, a PowerShell-based GUI may be just what you need to use the same codebase to give:

  • help desk personnel the ability to carry out tasks without knowing PowerShell
  • administrators the ability to use the source code for their own purposes

Earlier in this review, I mentioned that I plan to use Adam's PowerShell Universal Dashboard framework to build an administrator-friendly front-end to PowerShell JEA. I can do the same thing with the GUI designer in PowerShell Pro Tools.

To get started, add a PowerShell WPF Window item to your Visual Studio project. As you can see in the next screenshot, PowerShell Pro Tools does most of the "code behind" work for you. Drag and drop on your GUI control surface, set some properties, wire up your events, package the application as an executable, and you're finished. Pretty impressive stuff, for sure.

Creating a PowerShell GUI application

Creating a PowerShell GUI application

Wrap-up ^

There's a lot more to PowerShell Pro Tools than I have the "whitespace" to tell you about. Here are some pointers to get you familiarized with the toolset's other major features:

As of April 2019, Adam charges $59.99 USD for a PowerShell Pro Tools single-user license. That single code will activate the toolset in Visual Studio, VSCode, and your PowerShell console host.

After testing this software, I've added it to my list of "must-install" tools for my Visual Studio work. My homework assignment is to kick the tires on VSCode next. Let us know what you think of PowerShell Pro Tools in the comments, and I'll catch you next time!

Join the 4sysops PowerShell group!

0
Share
0 Comments

Leave a reply

Your email address will not be published. Required fields are marked *

*

© 4sysops 2006 - 2019

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account