Uncategorized · December 10, 2020 0

The specified resource type cannot be found in the image file

While I was trying to read some system eventslog using Get-EventLog with Powershell, I got the below error with some (Not ALL) logs!

my query is shown below

$yesterday = (Get-Date).AddHours(-24)

Get-EventLog -LogName “system” -After $yesterday

below you see the error I got

Get-WinEvent : The specified resource type cannot be found in the image file
At line:1 char:1Get-WinEvent -LogName System | more
CategoryInfo : NotSpecified: (:) [Get-WinEvent], EventLogException
FullyQualifiedErrorId : The specified resource type cannot be found in the image
file,Microsoft.PowerShell.Comma nds.GetWinEventComman

the output screen looked like below (zoom your browser if you cant see)

it took me couple hours to figure out that this error is not related to Powerhsell and there is not much to check or correct; in Fact the error is rather happening with only some events as they are missing something in the log itself!

Workaround

to tackle this issue, I have used Get-WinEvent instead and combined with -FilterHashTable so that I make my inquiry more specific to avoid the logs that threw the error

below is an example what worked for me without throwing any errors

$yesterday = (Get-Date).AddHours(-24)

Get-WinEvent -FilterHashTable @{LogName= ‘System’ ; StartTime=$yesterday} -ErrorAction SilentlyContinue

Cheers!

I hope you got something to start with. If you interested, I invite you to read my other article good bye Get-EventLog

Jaber Al-Ani

Close Bitnami banner
Bitnami