PowerShellTab Nesnesi

PowerShellTab nesnesi bir Windows PowerShell çalışma zamanı ortamını temsil eder.

Yöntemler

Invoke( Betik )

Windows PowerShell ISE 2.0 ve sonraki sürümlerde desteklenir.

Verilen betiği PowerShell sekmesinde çalıştırır.

Not

Bu yöntem yalnızca diğer PowerShell sekmelerinde çalışır, çalıştırıldığı PowerShell sekmesinde çalışmaz. Herhangi bir nesne veya değer döndürmez. Kod herhangi bir değişkeni değiştirirse, bu değişiklikler komutun çağrıldığı sekmede kalır.

Betik - System.Management.Automation.ScriptBlock veya Dize Çalıştırılacak betik bloğu.

# 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( Betik, [useNewScope], milisecondsTimeout )

Windows PowerShell ISE 3.0 ve sonraki sürümlerde desteklenir ve önceki sürümlerde mevcut değildir.

Verilen betiği PowerShell sekmesinde çalıştırır.

Not

Bu yöntem yalnızca diğer PowerShell sekmelerinde çalışır, çalıştırıldığı PowerShell sekmesinde çalışmaz. Betik bloğu çalıştırılır ve betikten döndürülen tüm değerler komutu çağırdığınız çalıştırma ortamına döndürülür. Komutun çalıştırılması millesecondsTimeout değerinin belirttiğinden daha uzun sürüyorsa, komut şu özel durumla başarısız olur: "İşlem zaman aşımına uğradı."

Betik - System.Management.Automation.ScriptBlock veya Dize Çalıştırılacak betik bloğu.

[useNewScope] - Varsayılan olarak $true Olarak ayarlanmış $trueolan isteğe bağlı Boole değeri, içinde komutun çalıştırıldığı yeni bir kapsam oluşturulur. Komutu tarafından belirtilen PowerShell sekmesinin çalışma zamanı ortamını değiştirmez.

[milisaniyeTimeout] - Varsayılan olarak 500 olan isteğe bağlı tamsayı. Komut belirtilen süre içinde tamamlanmazsa, komut "İşlem zaman aşımına uğradı" iletisiyle bir TimeoutException oluşturur.

# 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)}

Properties

AddOnsMenu

Windows PowerShell ISE 2.0 ve sonraki sürümlerde desteklenir.

PowerShell sekmesinin Eklentiler menüsünü alan salt okunur özellik.

# 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

Windows PowerShell ISE 2.0 ve sonraki sürümlerde desteklenir.

Bir betik Invoke( Betik ) yöntemiyle çağrılabiliyorsa değer $true döndüren salt okunur Boole özelliği.

# 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

Windows PowerShell ISE 3.0 ve sonraki sürümlerde desteklenir ve önceki sürümlerde mevcut değildir. Windows PowerShell ISE 2.0'da bu, CommandPane olarak adlandırılmıştır.

Konsol bölmesi düzenleyicisi nesnesini alan salt okunur özellik.

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

DisplayName

Windows PowerShell ISE 2.0 ve sonraki sürümlerde desteklenir.

PowerShell sekmesinde görüntülenen metni alan veya ayarlayan read-write özelliği. Varsayılan olarak, sekmeler "PowerShell #" olarak adlandırılır ve burada # bir sayıyı temsil eder.

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

ExpandedScript

Windows PowerShell ISE 2.0 ve sonraki sürümlerde desteklenir.

Betik bölmesinin genişletildiğini veya gizlendiğini belirleyen okuma-yazma Boole özelliği.

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

Dosyalar

Windows PowerShell ISE 2.0 ve sonraki sürümlerde desteklenir.

PowerShell sekmesinde açık olan betik dosyalarının koleksiyonunu alan salt okunur özellik.

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

Çıktı

Bu özellik Windows PowerShell ISE 2.0'da mevcuttur, ancak ISE'nin sonraki sürümlerinde kaldırılmıştır veya yeniden adlandırılmıştır. Windows PowerShell ISE'nin sonraki sürümlerinde ConsolePane nesnesini aynı amaçlarla kullanabilirsiniz.

Geçerli düzenleyicinin Çıkış bölmesini alan salt okunur özellik.

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

İstem

Windows PowerShell ISE 2.0 ve sonraki sürümlerde desteklenir.

Geçerli istem metnini alan salt okunur özellik. Not: İstem işlevi kullanıcının ™profili tarafından geçersiz kılınabilir. Sonuç basit bir dizeden farklıysa, bu özellik hiçbir şey döndürmez.

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

Komutları Göster

Windows PowerShell ISE 3.0 ve sonraki sürümlerde desteklenir ve önceki sürümlerde mevcut değildir.

Komutlar bölmesinin şu anda görüntülenip görüntülenmediğini gösteren read-write özelliği.

# 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

Windows PowerShell ISE 2.0 ve sonraki sürümlerde desteklenir.

PowerShellTab durum metnini alan salt okunur özellik.

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

HorizontalAddOnToolsPaneOpened

Windows PowerShell ISE 3.0 ve sonraki sürümlerde desteklenir ve önceki sürümlerde mevcut değildir.

Yatay Eklentiler araç bölmesinin şu anda açık olup olmadığını gösteren salt okunur özellik.

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

VerticalAddOnToolsPaneOpened

Windows PowerShell ISE 3.0 ve sonraki sürümlerde desteklenir ve önceki sürümlerde mevcut değildir.

Dikey Eklentiler araç bölmesinin şu anda açık olup olmadığını gösteren salt okunur özellik.

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

Ayrıca bkz: