Following on from the last instalment where I looked at supporting PowerShell script development in Visual Studio 2010, I’m going to take a closer look at PowerShell integration with the newer Visual Studio 2012.
Again, I’ll be leveraging the excellent Quest PowerGUI product and the associated Visual Studio extension.
Installation
You’ll also need PowerGUI 3.2, but this time there’s an updated Visual Studio extension which you’ll need, version 1.6.1.
Install PowerGUI 3.2 first, and once complete then install the Visual Studio extension. PowerGUI has a dependency on the .NET Framework 3.5, on newer OSes (like Windows 8) you might not have this pre-installed, don’t worry – the installer will warn you if anything’s missing.
Getting Started
Once you’ve installed, you will see a new option in Visual Studio’s File –> New Project dialog for PowerShell. This creates a fairly sparse new project with a .ps1 file in it ready to go.
Troubleshooting
The first two times I tried to get everything installed and running, I kept getting issues with Visual Studio 2012 warning it couldn’t load PowerGUI. I tried everything until I realised what the problem was. I’d downloaded the .vsix but one thing finally dawned on me:
Therefore, unblocking the file before installing seemed to do the trick. If you’re having problems loading the extension this might be a problem for you as well.
Looking at the Project
As with Visual Studio 2010, you get the PowerShell project type available in the New Project dialog:
A closer look
Some of the advantages of using Visual Studio to write your PowerShell scripts are easy to highlight. The debugging support is obviously a huge advantage, but so to is the Intellisense support.
It’s really evident when there’s an issue with the script, if you aren’t seeing the right info in Intellisense. Rather than go into detail, they say a picture is worth a thousand words, so let’s see some examples of the value in writing your PowerShell scripts in Visual Studio:
Best of all – Tooltips which provide CmdLet syntax
What’s Next?
Now that we’ve explored both Visual Studio 2010 and Visual Studio 2012 options for PowerShell, the next step is to take a look at some of the advantages of using either environment when building your PowerShell scripts. We’ll also look at trace/output options and how to best handle errors.
Check back for the next article..soon.
3 thoughts on “PowerShell and Visual Studio 2012”
Thanks for the nice overview, Rob!
It is a fantastic product — piece of mind. We were missing that in VS 2012.
However, I had to struggle for a while before discovering that debugging starts with F5. Please document that clearly for new comers.
BTW if you are running SERVER 2012, PowerShell v2 is NOT installed (only v1 and v3) so the PowerGUI 3.2 won’t install. I suspect similar behavior from Win8. I will go back and check if I can unblock the 3.2 Install.