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

431 Views Asked by At
$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?

1

There are 1 best solutions below

0
user459872 On BEST ANSWER

You have to add another key and value using Add method

$A.Add("ProviderName", "*UpdateClient")