Home > Blockchain >  How to include ProviderName in the command that gets event logs in the past ten hours
How to include ProviderName in the command that gets event logs in the past ten hours

Time:01-16

$A = @{}
$A.Add("StartTime", ((Get-Date).AddHours(-10)))
$A.Add("EndTime", (Get-Date))
$A.Add("LogName", "System")
(Get-WinEvent -FilterHashtable $A|Select TimeCreated, ProviderName, Message|FL)

The above commands will get all "System" event logs in the past 10 hours. However, I want to get only the event logs of "Microsoft-Windows-WindowsUpdateClient" in the past 10 hours. I tried the following line, which caused an error.

$A.Add("LogName", "System" ; "ProviderName", "*UpdateClient")

How should I include "ProviderName" in the command?

CodePudding user response:

You have to add another key and value using Add method

$A.Add("ProviderName", "*UpdateClient")
  •  Tags:  
  • Related