结果只显示一列? [英] show just one column in result?

查看:54
本文介绍了结果只显示一列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个简单的问题,但如何在下面的代码中选择特定的列?

Bit of a simple question but how do I select a specific column in the below code?

我只想显示 TIME 列,别无其他.我尝试输入 FORMAT_TABLE TIME 但它只是多次填充 TIME 而没有实际显示时间..

I only want to show TIME column and nothing else. I try and put in FORMAT_TABLE TIME but it just populates with TIME multiple times without actually showing the time..

$server_event = Get-Content -Path "c:\Temp\Servers.txt"

foreach($servers in $server_event)
{

$event = Get-EventLog -computerName $servers -logname system | Where-Object {$_.EventID -eq 6009} | Select -First 1

$event

} 

结果:我只想显示时间列

RESULT: I ONLY WANT TO SHOW THE TIME COLUMN

   Index Time          EntryType   Source                 InstanceID Message                                                                                     
   ----- ----          ---------   ------                 ---------- -------                                                                                     
   78858 Jun 01 07:19  Information EventLog               2147489657 Microsoft (R) Windows (R) 5.02. 3790 Service Pack 2 Multiprocessor Free.                    
   46221 Jun 01 07:20  Information EventLog               2147489657 Microsoft (R) Windows (R) 5.02. 3790 Service Pack 2 Multiprocessor Free.                    
  214480 Jun 01 07:46  Information EventLog               2147489657 Microsoft (R) Windows (R) 5.02. 3790 Service Pack 2 Multiprocessor Free.                    
  461238 Jun 01 07:18  Information EventLog               2147489657 Microsoft (R) Windows (R) 5.02. 3790 Service Pack 2 Multiprocessor Free.                    
   70889 Jun 01 07:17  Information EventLog               2147489657 Microsoft (R) Windows (R) 5.02. 3790 Service Pack 2 Multiprocessor Free.                    
   52397 Jun 01 07:19  Information EventLog               2147489657 Microsoft (R) Windows (R) 5.02. 3790 Service Pack 2 Multiprocessor Free.                    
   42219 Jun 01 07:40  Information EventLog               2147489657 Microsoft (R) Windows (R) 5.02. 3790 Service Pack 2 Uniprocessor Free.     

推荐答案

尝试:

$event = Get-EventLog -computerName $servers -logname system | Where-Object {$_.EventID -eq 6009} | Select TimeGenerated -First 1

这篇关于结果只显示一列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆