Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources: Active Threads
Viewing all articles
Browse latest Browse all 8411

Early Filtering of Win32_NTLogEvent class

$
0
0

Hello All,

Can someone please help with the following query :)

if I do the following I have to wait until all warning events are collected by WMI before they are then passed down the pipeline to select the First 1. This slow the whole thing down, I therefore want to filter the first event only in the WQL query, but cannot see an option for that in WQL, any advise most welcome.


cls
Get-WmiObject -Query "select Message,EventCode,TimeWritten from Win32_NTLogEvent WHERE Type = 'Warning'" -ComputerName Windows2000 |
Select @{n="Created";e={[System.Management.ManagementDateTimeConverter]::ToDateTime($_.TimeWritten)}},EventCode,Message -First 1 |
FT -AutoSize -Wrap


Thanks all
Ernie


Viewing all articles
Browse latest Browse all 8411

Latest Images

Trending Articles



Latest Images