All posts tagged: ISE

PowerShell ISE Addon: Reset all ISE preferences

Ever since PowerShell v3.0 CTP build got released, I am using ISE as my primary script editor. I keep changing preferences such as colors, etc. The new feature in ISE v3 remembers the changes made to ISE options. While this is quite useful, sometimes resetting all the changes we did can become painful. I need to use Tool->Options dialog and then click the ‘Restore Defaults’ button Or we can use the $psise.Options.RestoreDefaults() method. I am not sure of any other method unless I missed it in the RTFM

PowerShell ISE Addon: Go to cursor

I have a few scripts that are thousands of lines long. When working with these scripts in ISE, I often start modifying some part of the code and then use scroll bar to move up and down to refer to other parts of the code. In this process, I naturally lose track of the cursor position. This happens quite often and started frustrating me. So, I wrote a simple addon that takes me back to where the cursor is and re-focuses editor window at the cursor position by scrolling back to that place

Adding header to newly created scripts in PowerShell ISE

Here is a simple function that you can use to add a script header everytime you create a new script file in PowerShell ISE. Jeff Hicks posted a function to create an addon menu option to do this. What I am showing here does not add any menu option. This function uses $psISE.CurrentPowerShellTab events and adds the header only to untitled files. 

How this one works is quite simple. We do an event subscription for the CollectionChanged event of $psISE.CurrentPowerShellTab object. Once we receive this event, we use the Add-Header function to insert the script header. While writing this, I found an issue (hopefully.!) with the ISE object model and I had to workaround that issue. The workaround I’d put is dirty but that is what I could find. Let me know if you have a better way to do this.  You can copy & paste this to your ISE profile and every time you open a new file, either using CTRL+N or File -> New, the script header as stored in $header gets inserted. This is how it …