如何显示消息中的某些行?
Get-EventLog -LogName Application -EntryType Error -Newest 10 -Message "*3CXPhone.exe*" |
Format-Table -wrap具体地说,在我的示例中,我只想显示1,2和7,8行。该怎么做呢?
See我的例子
发布于 2017-10-09 19:43:24
下面这样的代码应该可以做到:
$lines = Get-EventLog -LogName Application -EntryType Error -Newest 10 -Message "*.exe*"
for($i=1;$i -lt 10;$i++){
switch ($i)
{
1 {$lines[$i]}
2 {$lines[$i]}
7 {$lines[$i]}
8 {$lines[$i]}
}
}所以基本上你创建了一个数组$lines。并使用计数器$i将计数器与数组的索引进行匹配。
发布于 2017-10-09 20:12:41
Get-EventLog -LogName Application -EntryType Error -Newest 10 -Message "*.exe*" | where {$_.Message -like '*.exe*'} | Format-Table -wraphttps://stackoverflow.com/questions/46644970
复制相似问题