PowerShellTab 객체는 Windows PowerShell 런타임 환경을 나타냅니다.
메서드
Invoke( Script )
Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.
PowerShell 탭에서 주어진 스크립트를 실행합니다.
비고
이 방법은 실행되는 PowerShell 탭에서는 작동하지 않고, 다른 PowerShell 탭에서만 작동합니다. 객체나 값을 반환하지 않습니다. 코드가 변수를 수정하면, 그 변경 사항은 명령어가 호출된 탭에 계속 유지됩니다.
- 스크립트 - System.Management.Automation.ScriptBlock 또는 문자열 - 실행할 스크립트 블록.
# 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 )
Windows PowerShell ISE 3.0 이후 버전에서 지원되며, 이전 버전에는 포함되지 않습니다.
PowerShell 탭에서 주어진 스크립트를 실행합니다.
비고
이 방법은 실행되는 PowerShell 탭에서는 작동하지 않고, 다른 PowerShell 탭에서만 작동합니다. 스크립트 블록이 실행되고, 스크립트에서 반환된 값은 명령어를 호출한 실행 환경으로 반환됩니다. 명령어가 밀 레초 타임아웃 값보다 더 오래 걸리면, 예외가 있는 명령어는 실패합니다: "작업이 타임아웃되었습니다."
- 스크립트 - System.Management.Automation.ScriptBlock 또는 문자열 - 실행할 스크립트 블록.
-
[useNewScope] - 기본값인
$true선택적 불리언 - 로$true설정하면 명령어를 실행할 새로운 범위가 생성됩니다. 명령어로 지정한 PowerShell 탭의 런타임 환경을 수정하지 않습니다. - [밀리초 타임아웃] - 기본값이 500인 선택적 정수. - 명령어가 지정된 시간 내에 완료되지 않으면, 명령어는 "The operation has timed out"이라는 메시지가 포함된 TimeoutException 을 생성합니다.
# 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)}
속성
애드온 메뉴
Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.
PowerShell 탭의 Add-ons 메뉴를 가져오는 읽기 전용 속성입니다.
# 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
캔인보크
Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.
읽기 전용 불리언 속성으로, 스크립트를 $true) 메서드로 호출할 수 있을 때 값을 반환 합니다.
# 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
콘솔 패널
Windows PowerShell ISE 3.0 이후 버전에서 지원되며, 이전 버전에는 포함되지 않습니다. Windows PowerShell ISE 2.0에서는 이 기능을 CommandPane이라고 명명했습니다.
Console 창 편집기 객체를 가져오는 읽기 전용 속성입니다.
# Gets the Console Pane editor.
$psISE.CurrentPowerShellTab.ConsolePane
디스플레이 이름
Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.
PowerShell 탭에 표시되는 텍스트를 받거나 설정하는 읽기-쓰기 속성입니다. 기본적으로 탭 이름은 "PowerShell #"이며, 여기서 #은 숫자를 나타냅니다.
$newTab = $psISE.PowerShellTabs.Add()
# Change the DisplayName of the new PowerShell tab.
$newTab.DisplayName = 'Brand New Tab'
확장 스크립트
Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.
스크립트 창이 확장되었는지, 숨겨졌는지 결정하는 읽기-쓰기 불리언 속성입니다.
# Toggle the expanded script property to see its effect.
$psISE.CurrentPowerShellTab.ExpandedScript = !$psISE.CurrentPowerShellTab.ExpandedScript
Files
Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.
PowerShell 탭에서 열려 있는 스크립트 파일 모음 을 가져오는 읽기 전용 속성입니다.
$newFile = $psISE.CurrentPowerShellTab.Files.Add()
$newFile.Editor.Text = "a`r`nb"
# Gets the line count
$newFile.Editor.LineCount
출력
이 기능은 Windows PowerShell ISE 2.0에 존재하지만, 이후 버전의 ISE에서는 제거되거나 이름이 변경되었습니다. Windows PowerShell ISE의 최신 버전에서는 ConsolePane 객체를 같은 목적으로 사용할 수 있습니다.
현재 편집기의 출력 창을 가져오는 읽기 전용 속성입니다.
# Clears the text in the Output pane.
$psISE.CurrentPowerShellTab.Output.Clear()
프롬프트
Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.
현재 프롬프트 텍스트를 받는 읽기 전용 속성입니다. 참고: 이 prompt 기능은 사용자의 프로필에 의해 덮어쓸 수 있습니다. 결과가 단순 문자열이 아니라면, 이 속성은 아무것도 반환하지 않습니다.
# Gets the current prompt text.
$psISE.CurrentPowerShellTab.Prompt
쇼커맨드
Windows PowerShell ISE 3.0 이후 버전에서 지원되며, 이전 버전에는 포함되지 않습니다.
명령어 창이 현재 표시되어 있는지 나타내는 읽기-쓰기 속성입니다.
# 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}
상태텍스트
Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.
PowerShellTab 상태 텍스트를 받는 읽기 전용 속성입니다.
# Gets the current status text,
$psISE.CurrentPowerShellTab.StatusText
수평 추가 도구 창 열림
Windows PowerShell ISE 3.0 이후 버전에서 지원되며, 이전 버전에는 포함되지 않습니다.
수평 Add-Ons 도구 창이 현재 열려 있는지 나타내는 읽기 전용 속성입니다.
# Gets the current state of the horizontal Add-ons tool pane.
$psISE.CurrentPowerShellTab.HorizontalAddOnToolsPaneOpened
VerticalAddOnToolsPaneOpened(수직 추가 도구 창 열림)
Windows PowerShell ISE 3.0 이후 버전에서 지원되며, 이전 버전에는 포함되지 않습니다.
수직 Add-Ons 툴 창이 현재 열려 있는지 나타내는 읽기 전용 속성입니다.
# Turns on the Commands pane
$psISE.CurrentPowerShellTab.ShowCommands = $true
# Gets the current state of the vertical Add-ons tool pane.
$psISE.CurrentPowerShellTab.HorizontalAddOnToolsPaneOpened