Delen via


Het PowerShellTab-object

Het PowerShellTab-object vertegenwoordigt een Windows PowerShell-runtimeomgeving.

Methoden

Invoke( Script )

Ondersteund in Windows PowerShell ISE 2.0 en hoger.

Hiermee wordt het opgegeven script uitgevoerd op het tabblad PowerShell.

Notitie

Deze methode werkt alleen op andere PowerShell-tabbladen, niet op het PowerShell-tabblad van waaruit deze wordt uitgevoerd. Er worden geen objecten of waarden geretourneerd. Als de code een variabele wijzigt, blijven deze wijzigingen behouden op het tabblad waarop de opdracht is aangeroepen.

Script - System.Management.Automation.ScriptBlock of String Het scriptblok dat moet worden uitgevoerd.

# Manually create a second PowerShell tab before running this script.
# Return to the first PowerShell tab and type the following command
$psISE.PowerShellTabs[1].Invoke({dir})

InvokeSynchronous( Script, [useNewScope], millisecondenTimeout )

Ondersteund in Windows PowerShell ISE 3.0 en hoger en niet aanwezig in eerdere versies.

Hiermee wordt het opgegeven script uitgevoerd op het tabblad PowerShell.

Notitie

Deze methode werkt alleen op andere PowerShell-tabbladen, niet op het PowerShell-tabblad van waaruit deze wordt uitgevoerd. Het scriptblok wordt uitgevoerd en elke waarde die wordt geretourneerd vanuit het script, wordt geretourneerd naar de uitvoeringsomgeving van waaruit u de opdracht hebt aangeroepen. Als het langer duurt om de opdracht uit te voeren dan de millesecondsTimeout-waarde opgeeft, mislukt de opdracht met een uitzondering: 'Er is een time-out opgetreden voor de bewerking'.

Script - System.Management.Automation.ScriptBlock of String Het scriptblok dat moet worden uitgevoerd.

[useNewScope] - Optionele Booleaanse waarde die standaard $true wordt ingesteld op Indien ingesteld $true, wordt er een nieuw bereik gemaakt waarin de opdracht moet worden uitgevoerd. De runtime-omgeving van het PowerShell-tabblad dat door de opdracht is opgegeven, wordt niet gewijzigd.

[millisecondenTimeout] - Optioneel geheel getal dat standaard 500 is. Als de opdracht niet binnen de opgegeven tijd wordt voltooid, genereert de opdracht een TimeoutException met het bericht 'Er is een time-out opgetreden voor de bewerking'.

# Create a new PowerShell tab and then switch back to the first
$psISE.PowerShellTabs.Add()
$psISE.PowerShellTabs.SetSelectedPowerShellTab($psISE.PowerShellTabs[0])

# Invoke a simple command on the other tab, in its own scope
$psISE.PowerShellTabs[1].InvokeSynchronous('$x=1', $false)
# You can switch to the other tab and type '$x' to see that the value is saved there.

# This example sets a value in the other tab (in a different scope)
# and returns it through the pipeline to this tab to store in $a
$a = $psISE.PowerShellTabs[1].InvokeSynchronous('$z=3;$z')
$a

# This example runs a command that takes longer than the allowed timeout value
# and measures how long it runs so that you can see the impact
Measure-Command {$psISE.PowerShellTabs[1].InvokeSynchronous('sleep 10', $false, 5000)}

Eigenschappen

AddOnsMenu

Ondersteund in Windows PowerShell ISE 2.0 en hoger.

De eigenschap Alleen-lezen die het menu Invoegtoepassingen voor het PowerShell-tabblad ophaalt.

# 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

Ondersteund in Windows PowerShell ISE 2.0 en hoger.

De alleen-lezen booleaanse eigenschap die een $true waarde retourneert als een script kan worden aangeroepen met de methode Invoke( Script ) .

# 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

ConsolePane

Ondersteund in Windows PowerShell ISE 3.0 en hoger en niet aanwezig in eerdere versies. In Windows PowerShell ISE 2.0 heet dit CommandPane.

De eigenschap Alleen-lezen waarmee het editorobject van het consolevenster wordt opgehaald.

# Gets the Console Pane editor.
$psISE.CurrentPowerShellTab.ConsolePane

DisplayName

Ondersteund in Windows PowerShell ISE 2.0 en hoger.

De eigenschap lezen/schrijven waarmee de tekst wordt opgehaald of ingesteld die wordt weergegeven op het tabblad PowerShell. Tabbladen hebben standaard de naam 'PowerShell #', waarbij het #-getal een getal vertegenwoordigt.

$newTab = $psISE.PowerShellTabs.Add()
# Change the DisplayName of the new PowerShell tab.
$newTab.DisplayName = 'Brand New Tab'

ExpandedScript

Ondersteund in Windows PowerShell ISE 2.0 en hoger.

De booleaanse eigenschap lezen/schrijven die bepaalt of het deelvenster Script is uitgevouwen of verborgen.

# Toggle the expanded script property to see its effect.
$psISE.CurrentPowerShellTab.ExpandedScript = !$psISE.CurrentPowerShellTab.ExpandedScript

Bestanden

Ondersteund in Windows PowerShell ISE 2.0 en hoger.

De eigenschap Alleen-lezen die de verzameling scriptbestanden ophaalt die zijn geopend op het tabblad PowerShell.

$newFile = $psISE.CurrentPowerShellTab.Files.Add()
$newFile.Editor.Text = "a`r`nb"
# Gets the line count
$newFile.Editor.LineCount

Uitvoer

Deze functie is aanwezig in Windows PowerShell ISE 2.0, maar is verwijderd of hernoemd in latere versies van de ISE. In latere versies van Windows PowerShell ISE kunt u het ConsolePane-object voor dezelfde doeleinden gebruiken.

De eigenschap Alleen-lezen die het uitvoervenster van de huidige editor ophaalt.

# Clears the text in the Output pane.
$psISE.CurrentPowerShellTab.output.clear()

Prompt

Ondersteund in Windows PowerShell ISE 2.0 en hoger.

De eigenschap Alleen-lezen waarmee de huidige prompttekst wordt weergegeven. Opmerking: de functie Prompt kan worden overschreven door het profiel van de gebruiker â„¢. Als het resultaat niet een eenvoudige tekenreeks is, retourneert deze eigenschap niets.

# Gets the current prompt text.
$psISE.CurrentPowerShellTab.Prompt

ShowCommands

Ondersteund in Windows PowerShell ISE 3.0 en hoger en niet aanwezig in eerdere versies.

De eigenschap lezen/schrijven die aangeeft of het deelvenster Opdrachten momenteel wordt weergegeven.

# Gets the current status of the Commands pane and stores it in the $a variable
$a = $psISE.CurrentPowerShellTab.ShowCommands
# if $a is $false, then turn the Commands pane on by changing the value to $true
if (!$a) {$psISE.CurrentPowerShellTab.ShowCommands = $true}

StatusTekst

Ondersteund in Windows PowerShell ISE 2.0 en hoger.

De eigenschap Alleen-lezen waarmee de powerShellTab-statustekst wordt ophaalt.

# Gets the current status text,
$psISE.CurrentPowerShellTab.StatusText

HorizontalAddOnToolsPaneOpened

Ondersteund in Windows PowerShell ISE 3.0 en hoger en niet aanwezig in eerdere versies.

De eigenschap Alleen-lezen die aangeeft of het horizontale taakvenster voor invoegtoepassingen momenteel is geopend.

# Gets the current state of the horizontal Add-ons tool pane.
$psISE.CurrentPowerShellTab.HorizontalAddOnToolsPaneOpened

VerticalAddOnToolsPaneOpened

Ondersteund in Windows PowerShell ISE 3.0 en hoger en niet aanwezig in eerdere versies.

De eigenschap Alleen-lezen die aangeeft of het deelvenster verticale invoegtoepassingen momenteel is geopend.

# Turns on the Commands pane
$psISE.CurrentPowerShellTab.ShowCommands = $true
# Gets the current state of the vertical Add-ons tool pane.
$psISE.CurrentPowerShellTab.HorizontalAddOnToolsPaneOpened

Zie ook