Use PowerShell in Visual Studio?

This is a question that, I swear, comes up in every class I teach. "Can I use Visual Studio with PowerShell?"

Originally, the answer was "no." Nowadays, it depends on what you mean by "with."

Can you use Visual Studio to write PowerShell scripts? Yes - with a free-add in. The PowerGUI Visual Studio Extension basically embeds PowerGUI inside Visual Studio. You'll need PowerGUI, which is free, and the extension. I'm not positive that you get a lot of benefits that you wouldn't get in standalone PowerGUI, but I guess if you're used to Visual Studio it creates an environment you're comfortable with. I haven't used this myself as I'm not normally a Visual Studio guy - if you have, and you'd like to share some thoughts with others, drop a comment.

For me, Visual Studio is a pretty big install. Since I don't normally find myself writing VB and C# programs these days, I much prefer a smaller, lighter editor that's PowerShell-specific - like PrimalScript, PowerGUI, or PowerShell Plus. There's a new one I need to try out, too.

Something else to keep in mind: If your PowerShell scripts are so complex that Visual Studio starts to look attractive, consider whether or not you shouldn't be writing your code in C# or VB. You can still access PowerShell cmdlets to do work, and those more-powerful, more-structured languages might ultimately be an easier way to accomplish your task. Something to consider, at least. 

The other possible definition of "with" is "can I execute PowerShell commands while in Visual Studio?" Essentially, using PowerShell as a ".NET Immediate Window," which it's very well-suited for. Again, the answer is yes. Several folks have made extensions to bring PowerShell into a pane within the VS environment. PowerConsole is something to check out, as well, since it offers some interesting VS integration points. 

Have you run across other PSH+VS extensions/integrations? There are more and more every day, and I try to keep track of them all. Drop a comment, or shoot me an e-mail, and let me know what you've found. I'll update once I've accumulated a good list.

Speaking of classes - just a couple of weeks left to save a bundle at my Windows PowerShell Retreat. All-inclusive pricing includes your hotel, almost all your meals, deluxe class materials kit, and a lot more. Check out the details and sign up! It's going to be a blast - I've just found out the class will include someone from the Windows PowerShell team, who'll be helping me deliver key modules, soliciting feedback from the students, and hanging out all week with us!

Discuss this Blog Entry 2

on Jan 18, 2011

I'm the guy behind the PowerGUI VSX and I just wanted to point out a few benefits of using PowerGUI in Visual Studio. The first being that you can debug binary modules by seamlessly stepping from PowerShell script to C#\VB.NET code. See my post here: Another cool thing that was just added to the beta for 1.3 is access to the DTE (Visual Studio's automation object). More on that here:

I also wanted to point out StudioShell:

It will be a pretty cool addition and I think it will get a lot more people doing PowerShell in Visual Studio.


on Aug 26, 2012
.Net is great.. easy to study ...object oriented...flexible . ling.

Please or Register to post comments.

What's PowerShell with a Purpose Blog?

Don Jones demystifies Windows PowerShell.

Blog Archive

Sponsored Introduction Continue on to (or wait seconds) ×