Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive

My friend, Thom Schumacher, who has been leading the Arizona PowerShell User Group for the past few months, is getting to know PowerShell Studio. Like many of us, he came to PowerShell Studio from PowerShell ISE, so he looks for the “ISE way” to do things in PowerShell Studio.

“How do I use PSEdit in PowerShell Studio?,” Thom asked on Twitter. Here’s my answer.

Um, you don’t need it

Being very literal, you don’t need the PSEdit function in PowerShell Studio.

The PSEdit function, which is defined in and works only in PowerShell ISE (not in the ISE module), opens a script that you specify in a new PowerShell Tab, that is, a new runspace.

PSEdit: New PowerShell Tab = New Runspace

In ISE, you need to create a new runspace because, by default, everything that you run in ISE runs in the same runspace in its console. That’s obviously not the best test environment. A new runspace is an improvement, even though the new runspace still includes your personal PowerShell profiles and anything that they import or auto-load.

As a best practice test environment, by default, PowerShell Studio runs every script in a new runspace every time. It not only creates a new runspace for every script. It creates a new runspace each time you use Run, Run Selection, or Debug, even if you run them repeatedly on the same script. You always get a new runspace. And, that runspace never includes PowerShell profiles, so you don’t need to hide, move, or disable them.

If you need a persistent runspace to share content, like variables, use the PowerShell Studio Console Pane. Run the script from the console or use the Run in Console or Run Selection in Console commands. Commands that run in the same Debug session also share a persistent runspace.


A PSEdit to Open a Script in PowerShell Studio

But, that’s probably too literal. Many people who use the PSEdit function aren’t even worried about a runspace. They just want a console command that opens a new script in their favorite editor.

To open any script (.ps1), module (,psm1) in PowerShell Studio, use the Invoke-Item cmdlet or its alias, ii.

For example, this command opens the Get-CmdletAttributes.ps1 script in PowerShell Studio.

ii C:\Scripts\Get-CmdletAttributes.ps1

You can use Invoke-Item in any PowerShell console, including, but not limited to, the PowerShell console in PowerShell Studio.

The Invoke-Item cmdlet works because it opens the file in the program that is associated with that file type. When you install PowerShell Studio, the installer sets the file association for you.

A PSEdit to Open PowerShell Studio

When people ask for a “PSEdit” equivalent, sometimes they just want a console command to open PowerShell Studio.

My CurrentUserAllHosts PowerShell profile includes this function. I named it “SPS” for “SAPIEN PowerShell Studio.” It works anywhere in PowerShell. It’s not limited to PowerShell Studio.

When I want to open PowerShell Studio from any console (except the one in PowerShell Studio, of course), I type sps.

function sps
    $keyPath = 'HKLM:\Software\Sapien Technologies, Inc.\PowerShell Studio*'
    if ($key = (dir $keyPath | Sort-Object -Descending | Select-Object -First 1) -replace 'HKEY_LOCAL_MACHINE', 'HKLM:' )
       if ($path = Get-ItemProperty -Path $key -Name Path)
           Start-Process $path.Path
           Write-Error "Found PowerShell Studio. Cannot find path in $key."
        Write-Error "Cannot find PowerShell Studio on this computer."

So, there you have it. If you’ve just started using PowerShell Studio, and you need an equivalent for your favorite command in your previous tool, post your request on our PowerShell Studio forum or, if you don't have an active maintenance subscription, our Trial Software Questions forum.

June Blender is a technology evangelist at SAPIEN Technologies, Inc. You can reach her at This email address is being protected from spambots. You need JavaScript enabled to view it. or follow her on Twitter at @juneb_get_help.

If you have questions about our products, please post in our support forum.
For licensed customers, use the forum associated with your product in our Product Support Forums for Registered Customers.
For users of trial versions, please post in our Former and Future Customers - Questions forum.
Copyright © 2024 SAPIEN Technologies, Inc.