Open Scripts in a new tab in the PowerShell ISE using PSEdit

While at TechEd last week, PSEdit was used in one of the PowerShell sessions that I sat through. Afterwards a couple of friends asked me if I had ever heard of it and said they hadn't so I thought I would write a blog article about it to help spread the word.

PSEdit is a function that only exists in the PowerShell ISE. Type in PSEdit followed by the name of a PowerShell script and that script will be opened in a new tab in the ISE:

1psEdit .\Get-FSMORole.ps1

051814-1.jpg

Try the same thing in the PowerShell console and you'll end up with an error message:

1psEdit .\Get-FSMORole.ps1

051814-2.jpg

Since psEdit is a function and not a compiled cmdlet, you can take a look under the covers to see what it does behind the scenes:

1Get-Command -Name psEdit | Select-Object -ExpandProperty Definition

051814-3.jpg

There's very little help for psEdit and this is even after running Update-Help from within the PowerShell ISE:

1help psEdit

051814-4.jpg

Even though the filenames parameter doesn't show it accepting an array [], based on the code and a little testing, a common separated list can be used to open multiple scripts:

1psEdit -filenames '.\Get-FSMORole.ps1', '.\Get-Top10PRocesses.ps1'

051814-5.jpg

I've actually written a previous blog article to locate and open scripts in the PowerShell ISE that uses the same behind the scenes code as psEdit that you may also find interesting.

µ