Note
L’accès à cette page nécessite une autorisation. Vous pouvez essayer de vous connecter ou de modifier les répertoires.
L’accès à cette page nécessite une autorisation. Vous pouvez essayer de changer de répertoire.
L’objet PowerShellTab représente un environnement d’exécution PowerShell Windows.
Méthodes
Invoke( Script )
Pris en charge sous Windows PowerShell ISE 2.0 et versions ultérieures.
Exécute le script donné dans l’onglet PowerShell.
Note
Cette méthode ne fonctionne que sur d’autres onglets PowerShell, pas sur l’onglet PowerShell d’où elle est lancée. Il ne retourne aucun objet ni valeur. Si le code modifie une variable, ces changements persistent sur l’onglet contre lequel la commande a été invoquée.
- Script - System.Management.Automation.ScriptBlock ou String - Le bloc de script à exécuter.
# 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 )
Pris en charge dans Windows PowerShell ISE 3.0 et ultérieurs, et absent dans les versions antérieures.
Exécute le script donné dans l’onglet PowerShell.
Note
Cette méthode ne fonctionne que sur d’autres onglets PowerShell, pas sur l’onglet PowerShell d’où elle est lancée. Le bloc de script est exécuté et toute valeur retournée par le script est renvoyée à l’environnement d’exécution d’où vous avez invoqué la commande. Si la commande met plus de temps à s’exécuter que la valeur de délai de délai milleseconde , alors la commande échoue à une exception près : « L’opération a expiré. »
- Script - System.Management.Automation.ScriptBlock ou String - Le bloc de script à exécuter.
-
[useNewScope] - Booléen optionnel qui se règle par défaut à
$true- Si défini à$true, alors un nouveau scope est créé pour exécuter la commande. Il ne modifie pas l’environnement d’exécution de l’onglet PowerShell spécifié par la commande. - [millisecondesTimeout] - Entier optionnel qui est par défaut 500. - Si la commande ne se termine pas dans le temps spécifié, alors la commande génère une TimeOut Exception avec le message « L’opération a expiré ».
# 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)}
Propriétés
AddOnsMenu
Pris en charge sous Windows PowerShell ISE 2.0 et versions ultérieures.
La propriété de lecture seule qui obtient le menu Add-ons pour l’onglet 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
Pris en charge sous Windows PowerShell ISE 2.0 et versions ultérieures.
La propriété booléenne en lecture seule qui renvoie une $true valeur si un script peut être invoquée avec la méthode 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
Pris en charge dans Windows PowerShell ISE 3.0 et ultérieurs, et absent dans les versions antérieures. Dans Windows PowerShell ISE 2.0, cela s’appelait CommandPane.
La propriété en lecture seule qui reçoit l’objet éditeur du volet Console.
# Gets the Console Pane editor.
$psISE.CurrentPowerShellTab.ConsolePane
DisplayName
Pris en charge sous Windows PowerShell ISE 2.0 et versions ultérieures.
La propriété de lecture-écriture qui obtient ou définit le texte affiché dans l’onglet PowerShell. Par défaut, les tabulations sont nommées « PowerShell # », où le # représente un nombre.
$newTab = $psISE.PowerShellTabs.Add()
# Change the DisplayName of the new PowerShell tab.
$newTab.DisplayName = 'Brand New Tab'
ScriptÉtendu
Pris en charge sous Windows PowerShell ISE 2.0 et versions ultérieures.
La propriété booléenne de lecture-écriture qui détermine si le volet Script est étendu ou caché.
# Toggle the expanded script property to see its effect.
$psISE.CurrentPowerShellTab.ExpandedScript = !$psISE.CurrentPowerShellTab.ExpandedScript
Fichiers
Pris en charge sous Windows PowerShell ISE 2.0 et versions ultérieures.
La propriété en lecture seule qui obtient la collection de fichiers scripts ouverts dans l’onglet PowerShell.
$newFile = $psISE.CurrentPowerShellTab.Files.Add()
$newFile.Editor.Text = "a`r`nb"
# Gets the line count
$newFile.Editor.LineCount
Output
Cette fonctionnalité est présente dans Windows PowerShell ISE 2.0, mais a été supprimée ou renommée dans les versions ultérieures de l’ISE. Dans les versions ultérieures de Windows PowerShell ISE, vous pouvez utiliser l’objet ConsolePane pour les mêmes usages.
La propriété en lecture seule qui obtient le panneau de sortie de l’éditeur courant.
# Clears the text in the Output pane.
$psISE.CurrentPowerShellTab.Output.Clear()
Prompt
Pris en charge sous Windows PowerShell ISE 2.0 et versions ultérieures.
La propriété en lecture seule qui reçoit le texte d’invite courant. Note : la prompt fonction peut être remplacée par le profil de l’utilisateur. Si le résultat est autre qu’une simple chaîne, alors cette propriété ne retourne rien.
# Gets the current prompt text.
$psISE.CurrentPowerShellTab.Prompt
ShowCommands
Pris en charge dans Windows PowerShell ISE 3.0 et ultérieurs, et absent dans les versions antérieures.
La propriété lecture-écriture qui indique si le panneau Commandes est actuellement affiché.
# 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
Pris en charge sous Windows PowerShell ISE 2.0 et versions ultérieures.
La propriété en lecture seule qui reçoit le texte d’état PowerShellTab .
# Gets the current status text,
$psISE.CurrentPowerShellTab.StatusText
HorizontalAddOnToolsPanePaneOuvert
Pris en charge dans Windows PowerShell ISE 3.0 et ultérieurs, et absent dans les versions antérieures.
La propriété en lecture seule qui indique si le panneau d’outil Add-Ons horizontal est actuellement ouvert.
# Gets the current state of the horizontal Add-ons tool pane.
$psISE.CurrentPowerShellTab.HorizontalAddOnToolsPaneOpened
VerticalAddOnToolsPaneOuvert
Pris en charge dans Windows PowerShell ISE 3.0 et ultérieurs, et absent dans les versions antérieures.
La propriété en lecture seule indique si le panneau vertical Add-Ons outil est actuellement ouvert.
# Turns on the Commands pane
$psISE.CurrentPowerShellTab.ShowCommands = $true
# Gets the current state of the vertical Add-ons tool pane.
$psISE.CurrentPowerShellTab.HorizontalAddOnToolsPaneOpened