$FilterXML = '<QueryList>
<Query Id="0" Path="System">
<Select Path="System">*[System[Provider[@Name="Service Control Manager"] and (Level=2)]]</Select>
</Query>
</QueryList>'
$Errors = Get-WinEvent -FilterXml $FilterXML
$Errors = $Errors | ?{ $_.ToXml().Contains("SomeService") }
Problem is that for every object, Message property is null. I can get some info using method .ToXml(), but I can't get message that you could see in windows event viewer under general tab.
If I use Get-EventLog cmdlet, the message property returns string about some error.
The description for Event ID '-1073734793' in Source 'Service Control Manager' cannot be found. The local computer may not have the necessary registry information or mess age DLL files to display the message, or you may not have permission to access them. The following information is part of the event:'SomeService', '2', '0', '3', 'Run the configured recovery program'