简体   繁体   English

(PowerShell Studio 2014试用版)文本框中的输出不完整

[英](PowerShell Studio 2014 Trial) Incomplete output in textbox

I created a form using PowerShell Studio 2014 Trial with two controls ie a command button & a text button. 我使用PowerShell Studio 2014试用版创建了带有两个控件的表单,即命令按钮和文本按钮。 Below is the code for click event on button1- 以下是button1- click事件的代码

$button1_Click={

$results=Get-WinEvent -FilterHashtable @{ LogName = "application"; StartTime = "10/30/2014 12:00:01 AM"; EndTime = "10/30/2014 11:59:59 PM" }

$textbox1.Text=$results
}

When I execute this, it does not give the expected output containing logs. 当我执行此操作时,它不会提供包含日志的预期输出。

It displays- "System.Diagnostics.Eventing.Reader.EventLogRecord" 它显示- "System.Diagnostics.Eventing.Reader.EventLogRecord"

形成

However, if I run- 但是,如果我运行-

Get-WinEvent -FilterHashtable @{ LogName = "application"; StartTime = "10/30/2014 12:00:01 AM"; EndTime = "10/30/2014 11:59:59 PM" }

on PowerShell ISE, it shows all logs. 在PowerShell ISE上,它显示所有日志。

Like I said in my comment your getting the output you requested. 就像我在评论中说的那样,您将获得所需的输出。 PowerShell console handles object output with built-in cmdlets like Out-Default . PowerShell控制台使用内置cmdlet(例如Out-Default处理对象输出。 You said you wanted all that information but I'm guessing you wanted what was display by default. 您说您想要所有这些信息,但是我猜您想要默认显示的内容。 Therefore I would make results the following 因此,我将在以下结果

$results = Get-WinEvent -FilterHashtable @{ LogName = "application"; StartTime = "10/30/2014 12:00:01 AM"; EndTime = "10/30/2014 11:59:59 PM" } | Select provider,timecreated,id,leveldisplayname,message | Format-Table | Out-String -Width 1024

Use Select to get only what we want. 使用“ Select仅获取我们想要的。 Change this as you see fit. 根据需要更改此设置。 Use Format-Table to make fixed width output then pipe it into Out-String 使用Format-Table进行固定宽度的输出,然后将其通过管道Out-StringOut-String

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM