사용자 지정 출력을 현재 PowerShell 화면 (워크 플로 있음)에서 다른 PowerShell 화면으로 리디렉션 할 수 있어야합니다.)PowerShell 출력을 다른 Powershell 화면으로 리디렉션하는 방법
참고 ** 그것이 단순히 PowerShell에서 수행 또는 C#으로 아이 PowerShell을 프로세스 스트림을 여는 같은 것을 할 수 있다면
그래서 궁금 "라이브"해야하기 때문에 파일로 리디렉션하는 옵션이 없습니다.
는사용자 지정 출력을 현재 PowerShell 화면 (워크 플로 있음)에서 다른 PowerShell 화면으로 리디렉션 할 수 있어야합니다.)PowerShell 출력을 다른 Powershell 화면으로 리디렉션하는 방법
참고 ** 그것이 단순히 PowerShell에서 수행 또는 C#으로 아이 PowerShell을 프로세스 스트림을 여는 같은 것을 할 수 있다면
그래서 궁금 "라이브"해야하기 때문에 파일로 리디렉션하는 옵션이 없습니다.
는내가 다른 콘솔 창에 직접 작성하는 방법이라고 생각하지 않습니다 감사합니다.
가장 좋은 방법은 생성 환경 변수의 변경 사항을 감시하는 스크립트를 만드는 것입니다.
그런 다음 Start-Process, Invoke-Item 또는 다른 방법을 사용하여 새 콘솔 창에서이 스크립트를 시작할 수 있습니다 (여러 가지 방법이 있습니다).
다른 방법으로는 두 번째 콘솔이 아닌 WPF 또는 브라우저 창을 사용하여 UI 요소를 만들 수 있습니다.
Powershell Jobs (help about_Jobs)를 보았습니까?
은 여전히 미세 조정이 필요하지만, 솔기가
#
# Create the form - I simplified this a bit and eliminated some unnecessary complexity
#
Add-Type -AssemblyName System.Windows.Forms
$dForm = New-Object System.Windows.Forms.Form
$dForm.Size = new-object System.Drawing.Size @(640,480)
$dForm.BackColor = 'Black'
$dForm.Text = "Debug Information"
$dText = New-Object System.Windows.Forms.TextBox
$dText.BackColor = 'Black'
$dText.ForeColor = 'red'
$dText.ScrollBars = "both"
$dText.Dock = "fill"
$dText.Multiline = $true
$dText.Parent = $dForm
$dText.ReadOnly = $true
$dForm.Add_Shown({$dform.Activate()})
#
# Create the new runspace
#
$rs = [Management.Automation.Runspaces.RunspaceFactory]::CreateRunspace()
$rs.Open()
# pass in the form object...
$rs.SessionStateProxy.SetVariable("dForm", $dForm)
# and set up a synchronized data interchange object
# between the two runspaces...
$data = [hashtable]::Synchronized(@{text=""})
$rs.SessionStateProxy.SetVariable("data", $data)
# Start the pipeline so the form will display...
$p = $rs.CreatePipeline({ [void] $dForm.ShowDialog()})
$p.Input.Close()
$p.InvokeAsync()
#
# Utility routine to show the text. This routine
# puts the text to display into the shared synchronized
# object then calls invoke. It may be that the form
# is not actually ready so it traps this errors and the retrys after a delay...
function Add-TextToWindow()
{
PARAM(
[parameter(Position=0, Mandatory=$true, HelpMessage = "Require String name as value ", ValueFromPipeline = $True)]
[String]
[ValidateNotNullOrEmpty()]
$text
)
$data.text = $text
[eventhandler]$eh = { $this.AppendText($data.text) }
#$data.text
do
{
$retry = @($false)
trap [InvalidOperationException]
{
start-sleep -Milliseconds 100
$retry[0] = $true
continue
}
$dText.Invoke($eh, ($dText, [eventargs]::empty))
}
while($retry[0])
}
#
# Now loop for a while writing out some text...
#
#Add-TextToWindow "The date is $(get-date)`n"
#1..30 | %{ Add-TextToWindow "Some text $_`n"; start-sleep -milli 100 }
#Add-TextToWindow "The date is $(get-date)`n"
start-sleep 2
$dForm.Close()
$rs.Close()
당신은 파일에 로그인 할 수있는 일을하고 그 파일이 로그 뷰어에 살고 볼 수 흥미로운 뭔가. 내가 가장 좋아하는 로그 뷰어는 [LogExpert] (http://www.log-expert.de/)입니다. –