PowerShell with a Purpose Blog

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 ShellHub.com 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!

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.