O objeto PowerShellTab
O objeto de guia do PowerShell incorpora um ambiente de execução do Windows PowerShell. Um exemplo é $psISE.CurrentPowerShellTab.
Métodos
A seguir, estão métodos do objeto de guia do PowerShell.
Invoke(System.Management.Automation.ScriptBlock script)
Executa o script determinado na guia do PowerShell.
| Observação: |
|
Esse método só funciona em outras guias do PowerShell, e não na guia do PowerShell onde é executado. |
- script:
- Script a ser executado.
# Manually create a second PowerShell tab before running this script.
# Return to the first tab and type
$secondTab = $psise.PowerShellTabs[1]
$secondTab.Invoke({dir})
Propriedades
AddOnsMenu
Propriedade somente leitura que obtém o menu Complementos para a guia do 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
Propriedade booleana somente leitura que obtém um valor true caso um script possa ser invocado com o método Invoke(System.Management.Automation.ScriptBlock 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
Commandpane
Propriedade somente leitura que obtém o objeto editor do Painel de Comando.
# Gets the Command Pane editor. $psISE.CurrentPowerShellTab.CommandPane
DisplayName
Propriedade de leitura/gravação que obtém ou define o nome da guia do PowerShell.
$newTab = $psise.PowerShellTabs.Add() # Change the DisplayName of the new PowerShell tab. $newTab.DisplayName="Brand New Tab"
ExpandedScript
Propriedade booleana de leitura/gravação que determina se o Painel de Script será expandido ou ocultado.
# Toggle the expanded script property to see its effect. $PSise.CurrentPowerShellTab.ExpandedScript=!$PSise.CurrentPowerShellTab.ExpandedScript
Files
Propriedade somente leitura que obtém a coleção de arquivos de script abertos na guia do PowerShell.
$newFile = $psISE.CurrentPowerShellTab.Files.Add() $newFile.Editor.Text = "a`r`nb" # Gets the line count. $newFile.Editor.LineCount
Output
Propriedade somente leitura que obtém o editor de saída.
# Clears the text in the output. $psise.CurrentPowerShellTab.output.clear()
Prompt
Propriedade somente leitura que obtém o texto de prompt atual.
# Gets the current prompt text. $psISE.CurrentPowerShellTab.Prompt
StatusText
Propriedade somente leitura que obtém o texto de status de PowerShellTab.
# Gets the current status text, $psISE.CurrentPowerShellTab.StatusText