How to set PowerShell_ISE as your default PowerShell editor when working with files in tfs projects

Comments 0

Share to social media

Every good DBA and Developer keeps their code under source control. What? You don’t? Well, read this and then go and investigate it, there are plenty of options, some free, some you need to pay for. Getting that all sorted is content for another blog (or two!) so let’s get back to editing PowerShell files when you have them in a Visual Studio / TFS solution.

For some obscure reason Visual Studio doesnt recognise a ps1 file or offer any intellisense or code colouring like it does with VB, C, SQL etc. If you double click a ps1 file in Visual Studio it opens in a plain text editor that is little more evolved that Notepad. It is possible however to configure Visual Studio so that it passes the file editing duties over to an alternative editor application. Let’s look at how we do that, so that we get a better PowerShell experience.

Step 1 – open Visual Studio and locate a solution that contains some of your PowerShell files.

Step 2 – click the Tools menu and select External Tools

PS_editor01.png

Step 3

PS_editor02.png

  1. Add a new tool
  2. Give the new tool a title of your choosing
  3. Locate the new tool .exe
  4. Click OK

Step 4 – right click on a PS file in your VS folder and click ‘advanced’ on the pop up menu

PS_editor03.png

Step 5 – Click ‘view with’ on this advanced menu

PS_editor04.png

Step 6

PS_editor05.png

  1. Select PowerShell_ISE (or the editor you are adding as an external tool)
  2. Click ‘set as default
  3. Note that the (default) appears next to the program you chose
  4. Click OK

Now, check out a PowerShell file and then double click it and it will open in PowerShell_ISE where you will have all the benefits that come with that application.

Note: If you have PowerShell_ISE already started then the file will open as a new document in that application, if you don’t have the ISE open already then it will be started. This may not make a big difference to you unless you run the ISE under a different account for elevated permissions settings.

[edit – 7th Jan 2015]

It has come to my attention that the above screen shots are not based on a vanilla installation of Visual Studio. In order to get the ‘View with…’ option shown at Step 5 above you need to have the Microsoft Visual Studio Team Foundation Server Power Tools installed (https://visualstudiogallery.msdn.microsoft.com/b1ef7eb2-e084-4cb8-9bc7-06c3bad9148f). Be careful when you install this to choose the custom option and select to install the PowerShell Cmdlets feature.

Load comments

About the author

Jonathan Allen

See Profile

Jonathan Allen has been a SQL Server DBA since 1999, most enjoying performance tuning and development but also working with SSIS, SSRS to provide suitable business solutions. He is SQLSouthWest PASS Chapter Leader, blogs for Simple Talk, is a forum moderator at ask.sqlservercentral.com and is on Twitter. If you would like to find your nearest user group or just want to say hello then he would love to get an email from you.

Jonathan Allen's contributions