1

#PSTip Preview PowerShell script files in Windows Explorer Preview Pane

The Windows Explorer Preview Pane can display the contents of text files, graphics, and other file types without having to use external software.

To add new file types to preview, such as PowerShell scripts, run the following command:

PS> Set-ItemProperty Registry::HKEY_CLASSES_ROOT\.ps1 -Name PerceivedType -Value text

Here’s how it looks in regedit.exe after the value has been added.

Now navigate to your scripts folder and select a script file. If the preview pane is open and you don’t see the script content, turn preview off and then on (you can use the ALT+P shortcut twice) to force Explorer to read the Registry value. Now you should see its content displayed:

To enable preview for multiple extensions:

PS> Get-Item Registry::HKEY_CLASSES_ROOT\* -Include .ps1,.psm1,.psd1 | Set-ItemProperty -Name PerceivedType -Value text
Filed in: Columns, Tips and Tricks Tags: , ,

One Response to "#PSTip Preview PowerShell script files in Windows Explorer Preview Pane"

  1. bluejay says:

    Thanks for your article. I am trying to get preview pane to preview the target PDF when I select the shortcut to a PDF. I tried tweaking the registry for the “.lnk” key but it didn’t work.

    Appreciate your thoughts if any.

Leave a Reply

Submit Comment

© 2016 PowerShell Magazine. All rights reserved. XHTML / CSS Valid.
Proudly designed by Theme Junkie.
%d bloggers like this: