Tome's Land of IT

IT Notes from the Powertoe – Tome Tanasovski

Open a file in PowerShell ISE via cmdlet – Version 3 Update

A while back I posted an article that discusses a cmdlet I created that opens up text files in powershell ISE.  It’s fairly robust: It accepts pipeline, wildcards, handles multiple files, etc.  I was just transferring my profile over to my Windows 8 Server computer, and I decided to revisit the script for PowerShell ISE in version 3.0 of PowerShell.

If you are not aware, powershell_ise.exe now accepts a new parameter called -File :

powershell_ise.exe -help

The way that -File works is better than I expected.  It not only opens up a PowerShell ISE window, and then opens the file in it, but it will inject the file into a PowerShell ISE window if it is already open.  Here is the relevant bit of code to launch powershell_ise.exe from a powershell.exe host.

# $files is an array that contains the full path to every file that will be opened
start powershell_ise.exe -ArgumentList ('-file',($files -join ','))

You can download the full script on PoshCode.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: