PowerShell ISE Can Do a Lot More Than You Think

PowerShell ISE Can Do a Lot More Than You Think

  • Comments 16

In CTP2, we released the first version of PowerShell_ISE.  It was VERY rough and primitive and we came close to deciding to wait to CTP3 to ship it.  We decided to go head and ship it in CTP2 because the team got it to critical mass and we wanted to let the world know where we were going as soon as possible and get their feedback.

It's been a long time since CTP2 and with CTP3, I think you'll find a MUCH richer, MUCH more useful PowerShell_ISE.  I strongly encourage you to spend some time exploring it.  It supports a ton of new features (my favorite is graphical debugging).

After you've explored all the menu items and gotten a good idea of what it can do, you are ready to start partying because that is just the beginning of what PowerShell_ISE can do.  The reason for that is that PowerShell_ISE is programmable.

We don't have good documentation on the programming model at this point.  That may or may not change by the time we ship V1 (because we have a TON of things to document and 'to ship is to choose') but it shouldn't matter if you've embraced the PowerShell model of education through investigation.  With Get-Member (gm) - you can figure it all out yourself.  All you need is a starting point.  That staring point is $psIse.

PS Mod:\form> $psIse |GM

   TypeName: System.Management.Automation.Host.PSGHost

Name                  MemberType Definition                                                                      
----                  ---------- ----------                                                                      
Equals                Method     bool Equals(System.Object obj)                                                  
GetHashCode           Method     int GetHashCode()                                                               
GetType               Method     type GetType()                                                                  
ToString              Method     string ToString()                                                               
CurrentOpenedFile     Property   System.Management.Automation.Host.OpenedFile CurrentOpenedFile {get;}           
CurrentOpenedRunspace Property   System.Management.Automation.Host.OpenedRunspace CurrentOpenedRunspace {get;}   
OpenedRunspaces       Property   System.Management.Automation.Host.OpenedRunspaceCollection OpenedRunspaces {get;}
Options               Property   System.Management.Automation.Host.Options Options {get;}                        

PS Mod:\form> $psIse.CurrentOpenedRunspace

DisplayName : PowerShell 1
ToolsMenu   : System.Management.Automation.Host.PSMenuItem
StatusText  : Running script / selection.  Press Ctrl-Break to stop.
Prompt      : PS Mod:\form>
CommandPane : Microsoft.Windows.PowerShell.Gui.Internal.CommandEditor
Output      : Microsoft.Windows.PowerShell.Gui.Internal.OutputEditor
OpenedFiles : {Untitled1.ps1, Form.psm1, Untitled3.ps1*, Microsoft.PowerShellISE_profile.ps1...}
CanExecute  : False

PS Mod:\form> $psIse.CurrentOpenedRunspace |GM

   TypeName: System.Management.Automation.Host.OpenedRunspace

Name            MemberType Definition                                                                                                      
----            ---------- ----------                                                                                                      
PropertyChanged Event      System.ComponentModel.PropertyChangedEventHandler PropertyChanged(System.Object, System.ComponentModel.Propert...
Equals          Method     bool Equals(System.Object obj)                                                                                  
Execute         Method     System.Void Execute(string script)                                                                              
GetHashCode     Method     int GetHashCode()                                                                                               
GetType         Method     type GetType()                                                                                                  
ToString        Method     string ToString()                                                                                               
CanExecute      Property   System.Boolean CanExecute {get;}                                                                                
CommandPane     Property   System.Management.Automation.Host.EditorBase CommandPane {get;}                                                 
DisplayName     Property   System.String DisplayName {get;set;}                                                                            
OpenedFiles     Property   System.Management.Automation.Host.OpenedFileCollection OpenedFiles {get;}                                       
Output          Property   System.Management.Automation.Host.EditorBase Output {get;}                                                      
Prompt          Property   System.String Prompt {get;}                                                                                     
StatusText      Property   System.String StatusText {get;}                                                                                 
ToolsMenu       Property   System.Management.Automation.Host.PSMenuItem ToolsMenu {get;}                                                   

PS Mod:\form> # Output is obviously the Output window
PS Mod:\form> $psIse.CurrentOpenedRunspace.output |gm

   TypeName: Microsoft.Windows.PowerShell.Gui.Internal.OutputEditor

Name             MemberType Definition                                                                                                     
----             ---------- ----------                                                                                                     
PropertyChanged  Event      System.ComponentModel.PropertyChangedEventHandler PropertyChanged(System.Object, System.ComponentModel.Proper...
Clear            Method     System.Void Clear()                                                                                            
EnsureVisible    Method     System.Void EnsureVisible(int lineNumber)                                                                      
Equals           Method     bool Equals(System.Object obj)                                                                                 
Focus            Method     System.Void Focus()                                                                                            
GetHashCode      Method     int GetHashCode()                                                                                              
GetLineLength    Method     int GetLineLength(int lineNumber)                                                                              
GetType          Method     type GetType()                                                                                                 
InsertText       Method     System.Void InsertText(string text)                                                                            
Select           Method     System.Void Select(int startLine, int startColumn, int endLine, int endColumn)                                 
SetCaretPosition Method     System.Void SetCaretPosition(int lineNumber, int columnNumber)                                                 
ToString         Method     string ToString()                                                                                              
CaretColumn      Property   System.Int32 CaretColumn {get;}                                                                                
CaretLine        Property   System.Int32 CaretLine {get;}                                                                                  
LineCount        Property   System.Int32 LineCount {get;}                                                                                  
SelectedText     Property   System.String SelectedText {get;}                                                                              
Text             Property   System.String Text {get;set;} 



PS Mod:\form> # Now let's select the output for all lines that have
PS Mod:\form> # "Event" in them
PS Mod:\form> $psIse.CurrentOpenedRunspace.output.Text -Split "`n" |Select-String Event

PropertyChanged Event      System.ComponentModel.PropertyChangedEventHandler PropertyChanged(System.Object, System.ComponentModel.Propert...
PropertyChanged  Event      System.ComponentModel.PropertyChangedEventHandler PropertyChanged(System.Object, System.ComponentModel.Proper...
$psIse.CurrentOpenedRunspace.output.Text -Split "`n" |Select-String Event


So you can see from this thread that using what you already know about PowerShell, you can investigate the system and figure things out for yourself.  Once you figure something out - post it so that the rest of us can benefit from your exploration.  Remember, you can extend your environment by putting things into your profile.  Also remember that each host has its OWN profile so PowerShell_ISE has a different profile from PowerShell.exe.  You get at it via $PROFILE. 

Here is what I just put into my profile. Notice that I added it as a menu item as well.


Function Select-Output
[Parameter(Position = 0, Mandatory = $true,
HelpMessage="Text to select from the Output Window")]

[Parameter(Position = 1)]
     $psIse.CurrentOpenedRunspace.output.Text -Split "`n" |Select-String -Context:$Context -Pattern:$Pattern
$null = $psISE.CurrentOpenedRunspace.ToolsMenu.Submenus.Add("Select From Output", {Select-Output}, $null)


Jeffrey Snover [MSFT]
Windows Management Partner Architect
Visit the Windows PowerShell Team blog at:    http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at:  http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

Leave a Comment
  • Please add 5 and 5 and type the answer here:
  • Post
  • Hi Jeffrey,

    I don't have a toolsmenu property when I do $psise.currentOpenedRunspace |GM. I have all the other property and methods . Not sure why ...

    $psise.CurrentOpenedRunspace |GM

      TypeName: System.Management.Automation.Host.OpenedRunspace

    Name            MemberType Definition                                                                                                                      

    ----            ---------- ----------                                                                                                                      

    PropertyChanged Event      System.ComponentModel.PropertyChangedEventHandler PropertyChanged(System.Object, System.ComponentModel.PropertyChangedEventArgs)

    Equals          Method     System.Boolean Equals(Object obj)                                                                                              

    Execute         Method     System.Void Execute(String script)                                                                                              

    GetHashCode     Method     System.Int32 GetHashCode()                                                                                                      

    GetType         Method     System.Type GetType()                                                                                                          

    ToString        Method     System.String ToString()                                                                                                        

    CanExecute      Property   System.Boolean CanExecute {get;}                                                                                                

    CommandPane     Property   System.Management.Automation.Host.EditorBase CommandPane {get;}                                                                

    DisplayName     Property   System.String DisplayName {get;set;}                                                                                            

    OpenedFiles     Property   System.Management.Automation.Host.OpenedFileCollection OpenedFiles {get;}                                                      

    Output          Property   System.Management.Automation.Host.EditorBase Output {get;}                                                                      

    Prompt          Property   System.String Prompt {get;}                                                                                                    

    StatusText      Property   System.String StatusText {get;}

  • I'm also having an issue within ISE where most of my menu items are grayed out . I cannot step into a script .. I'm not sure if its setup correctly.

    My setup is :

    Vista SP1

    Powershell V2 CTP 3

    .net Framework 3.5 SP1



  • $null = $psISE.CurrentOpenedRunspace.ToolsMenu.Submenus.Add("Select From Output", {Select-Output}, $null)


    You cannot call a method on a null-valued expression.

    At line:1 char:53

    +  $psISE.CurrentOpenedRunspace.ToolsMenu.Submenus.Add <<<< ("Select From Output", {Select-Out

    put}, $null)

       + CategoryInfo          : InvalidOperation: (Add:String) [], RuntimeException

       + FullyQualifiedErrorId : InvokeMethodOnNull


    $null = $psIse.CustomMenu.Submenus.Add("Select From Output", {Select-Output}, $null)

    works fine.

  • The Windows PowerShell Integrated Scripting Environment (ISE) is a host application that enables you

  • These are the only options I have for $psISE.CurrentOpenedRunspace and fail on adding the menu.

    PS C:\Users\Mark E. Schill> $psISE.CurrentOpenedRunspace

    DisplayName : PowerShell 1

    StatusText  : Running

    Prompt      : PS C:\Users\Mark E. Schill>

    CommandPane : Microsoft.Windows.PowerShell.Gui.Internal.CommandEditor

    Output      : Microsoft.Windows.PowerShell.Gui.Internal.OutputEditor

    OpenedFiles : {Untitled1.ps1}

    CanExecute  : False

  • Hi Jeffery, I would like to know all ISE shortcut keys.

    For example, its Command Pane needs Shift+Enter for starting a new line since it was called Graphical PowerShell,

    but there are no documents yet.

  • Hi Smith,

    Please press F1 to display the ISE help file (in CHM format). Here are some useful links:

    1. For Shift+Enter, there's a whole topic dedicated to this, titled "How to Enter and Run a Command in the Command Pane".

    2. For shortcuts in general, there's a very nice reference page of all shortcuts, titled "Keyboard Shortcuts".

    Hope this helps. Enjoy.

    Refaat Issa [MSFT]

  • Hi Refaat Issa, thank you.

    In my environment, nothing occurs by F1...

    And, there was 'PowerShell_Core_M2' chm file at CTP2 in $PSHOME\en-US directory.

    But there aren't its alternative at CTP3 in $PSHOME and $PSHOME\* directories.

    My Windows XP SP2 isn't English, is this related?

  • Hello Jeffrey,

    many thanks for Select-Output.

    If it would be possible to determine which pane gets keyboard input,  


    could be used as alternate source for the selected string in Select-Output.

    Remember the count of keyboard-shortcuts is very finite.



  • I recently wrote a blog Powershell_Ise Can Do a Lot More Than You Think where I described the ability

  • Resolved.

    CTP3's chm file exist in %windir%\Help\MUI\0409\WindowsPowerShellHelp.chm .

    0409 means 'en-US' MUI code, so I needed to rename this directory to my own country code.

    I'm sorry for all the fuss.

  • Here is a collection of differences between the PowerShell_ise.exe and PowerShell.exe, as well as workarounds

  • Here is a collection of differences between the PowerShell_ise.exe and PowerShell.exe, as well as workarounds


    Powershell ISE needs a "jump to column number" hotkey.

  • I Use Powershell ISE And I Can Not Preform Netsh Or WMIC Tasks That I Need To Be Admin At My Company!!!!!

    So I Need:




    Someone Please Get A Powershell Developer On With This!!!!!!!

Page 1 of 2 (16 items) 12