The PowerShell tab object embodies a Windows PowerShell execution environment. An example is $psISE.CurrentPowerShellTab.
Methods
The following are methods of the PowerShell tab object.
Invoke(System.Management.Automation.ScriptBlock script)
Executes the given script in the PowerShell tab.
Note: | |
This method only works on other PowerShell tabs, not on the PowerShell tab where it is run. |
- script:
- Script to be executed.
# Manually create a second PowerShell tab before running this script. # Return to the first tab and type $secondTab = $psise.PowerShellTabs[1] $secondTab.Invoke({dir})
Properties
AddOnsMenu
Read-only property that gets the Add-ons menu for the PowerShell Tab.
# Clear the Add-ons menu if one exists. $psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Clear() # Create an AddOns menu with an accessor. # Note the use of “_” as opposed to the “&” for mapping to the fast key letter for the menu item. $menuAdded = $psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Add("_Process",{get-process},"Alt+P") # Add a nested menu. $parentAdded = $psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Add("Parent",$null,$null) $parentAdded.SubMenus.Add("_Dir",{dir},"Alt+D") # Show the Add-ons menu on the current PowerShell tab. $psISE.CurrentPowerShellTab.AddOnsMenu
CanInvoke
Read-only Boolean property that gets a true value if a script can be invoked with the Invoke(System.Management.Automation.ScriptBlock script) method.
# CanInvoke will be false if the PowerShell # tab is running a script that takes a while, and you # check its properties from another PowerShell tab. It is # always false if checked on the current PowerShell tab. # Manually create a second PowerShell tab before # running this script. # Return to the first tab and type $secondTab = $psise.PowerShellTabs[1] $secondTab.CanInvoke $secondTab.Invoke({sleep 20}) $secondTab.CanInvoke
Commandpane
Read-only property that gets the Command Pane editor object.
# Gets the Command Pane editor. $psISE.CurrentPowerShellTab.CommandPane
DisplayName
Read-write property that gets or sets the name of the PowerShell tab.
$newTab = $psise.PowerShellTabs.Add() # Change the DisplayName of the new PowerShell tab. $newTab.DisplayName="Brand New Tab"
ExpandedScript
Read/write Boolean property that determines whether the Script Pane is expanded or hidden.
# Toggle the expanded script property to see its effect. $PSise.CurrentPowerShellTab.ExpandedScript=!$PSise.CurrentPowerShellTab.ExpandedScript
Files
Read-only property that gets the collection of script files that are open in the PowerShell tab.
$newFile = $psISE.CurrentPowerShellTab.Files.Add() $newFile.Editor.Text = "a`r`nb" # Gets the line count. $newFile.Editor.LineCount
Output
Read-only property that gets the output editor.
# Clears the text in the output. $psise.CurrentPowerShellTab.output.clear()
Prompt
Read-only property that gets the current prompt text.
# Gets the current prompt text. $psISE.CurrentPowerShellTab.Prompt
StatusText
Read-only property that gets the PowerShellTab status text.
# Gets the current status text, $psISE.CurrentPowerShellTab.StatusText
See Also