PowerTip: Programmatically Open Script in PowerShell ISE

Summary: Use Windows PowerShell to open a script in the Windows PowerShell ISE.

Hey, Scripting Guy! Question How can I use Windows PowerShell to run a script that will open another script in a new tab
           in the Windows PowerShell ISE?

Hey, Scripting Guy! Answer Use the CurrentPowerShellTab Files Add method from the $psISE object, for example:


Comments (3)

  1. PowerShell Operater says:

    $psISE.CurrentPowerShellTab is the current tab and not a new tab

    Should be
    $tab = $psISE.PowerShellTabs.Add()

  2. M.T.Nielsen says:

    Or you could use the conveniently built-in alias "ise":

    ise test.ps1

  3. Christopher says:

    Powershell Operator,
    It depends on your definition of tab. In Powershell parlance, you are correct, a new tab implies a new powershell session. But for common usage, when someone says they want to open a file in a new tab in ISE, they usually mean open a file in a new window in
    the current session (i.e. the current tab), the new file is in its own window and the windows themselves are tabbed. Therefore I would say that the scripting guy’s answer is the most correct. But the knowledge you provided here is useful in and of itself.
    Thank you!

Skip to main content