Nota
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare ad accedere o modificare le directory.
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare a modificare le directory.
L'oggetto PowerShellTab rappresenta un ambiente di esecuzione PowerShell di Windows.
Methods
Invoke( Script )
Supportato in Windows PowerShell ISE 2.0 e versioni successive.
Esegue lo script fornito nella scheda PowerShell.
Annotazioni
Questo metodo funziona solo su altre schede PowerShell, non su quella da cui viene eseguito. Non restituisce alcun oggetto o valore. Se il codice modifica una variabile, tali modifiche persistono nella scheda contro cui è stato invocato il comando.
- Script - System.Management.Automation.ScriptBlock o Stringa - Il blocco script da eseguire.
# 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], millisecondsTimeout )
Supportato in Windows PowerShell ISE 3.0 e successivi, e non presente nelle versioni precedenti.
Esegue lo script fornito nella scheda PowerShell.
Annotazioni
Questo metodo funziona solo su altre schede PowerShell, non su quella da cui viene eseguito. Il blocco script viene eseguito e qualsiasi valore restituito dallo script viene restituito all'ambiente run da cui hai invocato il comando. Se il comando impiega più tempo a essere eseguito rispetto al valore di timeout dei millesecondi , allora il comando fallisce con un'eccezione: "L'operazione è terminata."
- Script - System.Management.Automation.ScriptBlock o Stringa - Il blocco script da eseguire.
-
[useNewScope] - Boolean opzionale che predefinito è -
$trueSe impostato su$true, allora viene creato un nuovo scope all'interno del quale eseguire il comando. Non modifica l'ambiente di esecuzione della scheda PowerShell specificata dal comando. - [millisecondi Timeout] - Intero opzionale che di default è 500. - Se il comando non termina entro il tempo specificato, allora il comando genera una TimeoutException con il messaggio "L'operazione ha terminato il tempo."
# 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)}
Proprietà
AddOnsMenu
Supportato in Windows PowerShell ISE 2.0 e versioni successive.
La proprietà di sola lettura che mostra il menu Add-on per la scheda PowerShell.
# 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
Supportato in Windows PowerShell ISE 2.0 e versioni successive.
La proprietà booleana di sola lettura che restituisce un $true valore se uno script può essere invocato con il metodo 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's
# 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
Supportato in Windows PowerShell ISE 3.0 e successivi, e non presente nelle versioni precedenti. In Windows PowerShell ISE 2.0 questo era chiamato CommandPane.
La proprietà di sola lettura che riceve l'oggetto dell'editor del pannello Console.
# Gets the Console Pane editor.
$psISE.CurrentPowerShellTab.ConsolePane
Nome visualizzato
Supportato in Windows PowerShell ISE 2.0 e versioni successive.
La proprietà di lettura-scrittura che ottiene o imposta il testo che viene visualizzato nella scheda PowerShell. Di default, le tabulazioni sono chiamate "PowerShell #", dove il # rappresenta un numero.
$newTab = $psISE.PowerShellTabs.Add()
# Change the DisplayName of the new PowerShell tab.
$newTab.DisplayName = 'Brand New Tab'
ScriptscriptEspanso
Supportato in Windows PowerShell ISE 2.0 e versioni successive.
La proprietà booleana di lettura-scrittura determina se il pannello Script è espanso o nascosto.
# Toggle the expanded script property to see its effect.
$psISE.CurrentPowerShellTab.ExpandedScript = !$psISE.CurrentPowerShellTab.ExpandedScript
File
Supportato in Windows PowerShell ISE 2.0 e versioni successive.
La proprietà di sola lettura che ottiene la raccolta di file script aperti nella scheda PowerShell.
$newFile = $psISE.CurrentPowerShellTab.Files.Add()
$newFile.Editor.Text = "a`r`nb"
# Gets the line count
$newFile.Editor.LineCount
Risultato
Questa funzione è presente in Windows PowerShell ISE 2.0, ma è stata rimossa o rinominata nelle versioni successive dell'ISE. Nelle versioni successive di Windows PowerShell ISE, puoi usare l'oggetto ConsolePane per gli stessi scopi.
La proprietà di sola lettura che ottiene il pannello Output dell'editor corrente.
# Clears the text in the Output pane.
$psISE.CurrentPowerShellTab.Output.Clear()
Rapido
Supportato in Windows PowerShell ISE 2.0 e versioni successive.
La proprietà di sola lettura che riceve il testo di prompt corrente. Nota: la prompt funzione può essere sovrascritta dal profilo dell'utente. Se il risultato è diverso da una stringa semplice, allora questa proprietà non restituisce nulla.
# Gets the current prompt text.
$psISE.CurrentPowerShellTab.Prompt
ShowCommands
Supportato in Windows PowerShell ISE 3.0 e successivi, e non presente nelle versioni precedenti.
La proprietà di lettura-scrittura che indica se il pannello Comandi è attualmente visualizzato.
# 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}
StatusText
Supportato in Windows PowerShell ISE 2.0 e versioni successive.
La proprietà di sola lettura che riceve il testo di stato PowerShellTab .
# Gets the current status text,
$psISE.CurrentPowerShellTab.StatusText
HorizontalAddOnToolsPaneAperto
Supportato in Windows PowerShell ISE 3.0 e successivi, e non presente nelle versioni precedenti.
La proprietà di sola lettura che indica se il pannello orizzontale Add-Ons strumento è attualmente aperto.
# Gets the current state of the horizontal Add-ons tool pane.
$psISE.CurrentPowerShellTab.HorizontalAddOnToolsPaneOpened
VerticalAddOnToolsPaneAperto
Supportato in Windows PowerShell ISE 3.0 e successivi, e non presente nelle versioni precedenti.
La proprietà di sola lettura indica se il pannello verticale Add-Ons strumento è attualmente aperto.
# Turns on the Commands pane
$psISE.CurrentPowerShellTab.ShowCommands = $true
# Gets the current state of the vertical Add-ons tool pane.
$psISE.CurrentPowerShellTab.HorizontalAddOnToolsPaneOpened