I must say I am very impressed by the PowerShell ISE editor. It has so many cool features that I thought I would write a little blogpost about them.
Tip 1 – Help on CMDlets:
If you place the insertion pointer inside a cmdlet you can press F1 and get detailed help about it.
Tip 2 – Help from TechNet:
If you are tired of running «Update-help» to get fresh help content, you can change PowerShell ISE to get the help content directly from TechNet whenever you request help. By doing this you change the behavior and PowerShell ISE will open the correct TechNet webpage instead of displaying it in the editor.
To do that go into «Tools –> Options»
and then on the «General settings» tab you will find the «Use local help instead of online content» option. If you clear this checkbox you will get help content directly from TechNet:
I personally prefer to run update-help and get help from inside the editor, but still it is a nice feature to know about.
Tip 3 – Multi-select:
Often you need to change multiple lines at the same time. There is a neat shortcut for multi-selecting lines. If you hold down ALT+SHIFT you will be able to multi-select and edit multiple lines at the same time.
Tip 4 – Snippets:
Often you find yourself writing foreach that actually is always the same. Why not use snippets? This is a built in feature in PowerShell ISE. Just hit CTRL+J and you will get a menu to choose from. It contains a lot of pre-created code to choose from.
You can also create your own snippets. More information on that can be found here: http://www.jonathanmedd.net/2013/11/creating-powershell-ise-v3-and-later-code-snippets.html
Tip 5 – Regions:
Sometimes when you have a massive amount of code you want to hide parts of the code to make it easier to view it. In PowerShell ISE it is possible to add #region and #regionend to be able to hide code from the editor.
Tip 6 – Presentation theme:
Often when I want to show/demonstrate some code on a bad projector I often use CTRL+Mousewheel to zoom in. This is not always a success, but there is a better way. PowerShell ISE has a presentation theme you can turn on. Go into tools –> options and select the manage themes button:
If you choose the presentation theme all the font is resized so it is easier for people in an audience to see it.
This will really blow up the text and it will be visible from a mile away.
Tip 7 – Script Browser and Analyzer:
If you do not have the script Browser and Analyzer plugin then you need to install it. This will really help you write more “correct” code. Just go into Add-ons and click «Get Script analyzer Add-on Tool». This will open a browser to the following link:
Download the file and install it. It’s a next, next, finish installation. After it is installed you often need to restart the ISE editor. You should now have 2 new tabs on the right side:
Under the Script Analyzer you can start «Scan Script» and it will tell you if you have any issues with the script that you should know about.
The script browser is also genius. This plugin lets you search TechNet script library from within the ISE editor. Just type what you need and it will search for a script. In my case I searched for Password generator:
Right click on the script you want and hit download. One thing that is missing is that you can open the script directly into the ISE from the “Script Browser”, but still very useful.
There is also a comprehensive community list of plugins:
I have not tried everyone, but there some great plugins for sure.
Tip 8 – Breakpoints:
This is probably one of the most overlooked features in PowerShell ISE. Did you know that if you for example are calling a function you can set a breakpoint inside the function or before the call of a function to view the values?
In this GIF it will show how I set breakpoint and how I view the variables by hovering over with mouse and I can also type it in.
When a the script comes to the breakpoint you can type ? to view the different options. Q quits and does not continue past the breakpoint. C continues the script to completion or next breakpoint.
If you are interested in knowing all the defined shortcuts in PowerShell ISE they can be found in a great blogpost here: http://www.powershellmagazine.com/2013/01/29/the-complete-list-of-powershell-ise-3-0-keyboard-shortcuts/
A feature that I want see in the future is the ability to duplicate a line with a shortcut. In other editors you can for example use CTRL+D and it will duplicate the line you are currently working on. That would be awesome!
It is not possible to show all the things that are cool with PowerShell ISE, but I hoped you liked this post and that you picked up a tip or two.
Tip 9 – Duplicate line
One of the features that I was missing was acutally present in the ISE editor all along. All you need to do to duplicate a line is to use CTRL+C and then CTRL+V without marking any text. It will then duplicate the line you are currently working on.