This may have been asked/answered before, but I could not locate it in the search option.
I have a simple “Event Log” script that works in Server 2008 R2, but not Server 2008. Both Servers have default PS installations (V2):
$yesterday = (Get-Date) - (New-TimeSpan -Day 1)
Get-WinEvent -FilterHashTable @{LogName=‘System’; Level=2,3; StartTime=$yesterday}
Error in Server 2008 (non R2):
Get-WinEvent : The parameter is incorrect
At line:2 char:13
- Get-WinEvent <<<< -FilterHashTable @{LogName='System'; Level=2,3; StartTime=$yesterday}
- CategoryInfo : NotSpecified: ( [Get-WinEvent], EventLogException
- FullyQualifiedErrorId : System.Diagnostics.Eventing.Reader.EventLogException,Microsoft.PowerShell.Commands.GetWinEventCommand
I assume this could be solved with an upgrade to a newer version of PS, but was curious of various (if any) solutions.
Thanks,
Stephen C