PowerShell Editor Is Slow Starting Up When You Are Browsing Code? Speed It Up to Instant! Print E-mail
Written by Darwin Sanoy   
Wednesday, October 16, 2013 12:14pm
Dedicated PowerShell ISEs and IDEs all seem to be slow starting up.  Some are worse than others, but they are all painfully slow compared to good old notepad.  For code peeking we've got somethat is even faster than notepad! 

Whether you use the PowerShell ISE, Admin Script Editor (ASE), Idera's PowerShell Plus, PowerGUI, PowerSE, Primal Script or any of the others - they all take significant time to wake up and smell the coffee!

One of the daily uses of a code editor is to take a peek at code when you are looking for a few lines you remember using in the past.

For this specific operation we've got something that even faster than Notepad - it's instant.

The following PowerShell oneliner configures Windows Explorer's built in Plain Text viewer to be the default viewer for all PowerShell file types including scripts (.ps1) and modules (.psm1).

managingtheenterprisewindowsdesktopwithpowershelltitlegraphic320 For more explanation and updated Ready-To-Run code for this topic, check out our video course "PSH-205 Managing the Enterprise Windows Desktop with PowerShell"
[ Free for a limited time ]

Unfortunately if you install a new PowerShell editor it may update the file type association of some of these files and the viewer support stops working.  If that happens, simple re-run the below snippet to re-register the plain text viewer.

A second example below shows how to enable it for VBS, CMD, BAT, REG and XML.  You can add the extension of any file type that is internally "plain text".

#PowerShell File Types

@(".ps1",".ps1xml",".psc1",".psd",".psd1",".psd1",".psm1") | % {New-Item -Force -Path "HKLM:\Software\Classes\$((get-itemproperty -literalpath HKLM:\SOFTWARE\Classes\$_).'(default)')\shellex\{8895b1c6-b41f-4c1c-a562-0d564250836f}" -Value "{1531d583-8375-4d3f-b5fb-d23bbd169f22}" }

#Some additional file types that are handy to view in Windows Explorer
@(".vbs",".cmd",".bat",".reg",".xml") | % {New-Item -Force -Path "HKLM:\Software\Classes\$((get-itemproperty -literalpath HKLM:\SOFTWARE\Classes\$_).'(default)')\shellex\{8895b1c6-b41f-4c1c-a562-0d564250836f}" -Value "{1531d583-8375-4d3f-b5fb-d23bbd169f22}" }

For editing your scripts you can also make your editor nearly instant by changing your approach to Integrated Script Development Environments - think of them like Outlook - open it once and leave it open all day!