Repository navigation
Labels
Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.WG-Cmdletsgeneral cmdlet issues
Description
Steps to reproduce
Get-WinEventExpected behavior
A user friendly error message when running from a non-elevated session, stating that elevated permissions is needed.
I would suggest that the behavior of the default parameter set prompts for required parameters rather than returning cryptic error messages. For example, prompt for the -LogName parameter if no parameters is supplied.
Actual behavior
Get-WinEvent : Could not retrieve information about the Security log. Error: Attempted to perform an unauthorized operation..
At line:1 char:1
+ Get-WinEvent
+ ~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-WinEvent], Exception
+ FullyQualifiedErrorId : LogInfoUnavailable,Microsoft.PowerShell.Commands.GetWinEventCommand
Get-WinEvent : The data is invalid
At line:1 char:1
+ Get-WinEvent
+ ~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-WinEvent], EventLogInvalidDataException
+ FullyQualifiedErrorId : The data is invalid,Microsoft.PowerShell.Commands.GetWinEventCommand
The "Get-WinEvent : The data is invalid" error is repeated many times, regardless of running elevated or not.
Environment data
Name Value
---- -----
PSVersion 6.2.3
PSEdition Core
GitCommitId 6.2.3
OS Microsoft Windows 10.0.17763
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Reacted by Michael Klement and Ilya
Metadata
Metadata
Assignees
Labels
Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.WG-Cmdletsgeneral cmdlet issues
Activity
iSazonov commentedon Sep 27, 2019
Really here is two issues.
Get-WinEvent : The data is invalidcase)janegilring commentedon Sep 27, 2019
Ok, should I edit this issue to only include the first, and create a separate issue for the latter?
iSazonov commentedon Sep 27, 2019
Jan Egil Ring (@janegilring) You could open new issue for your suggestioniSazonov commentedon Sep 27, 2019
I pulled #10639 to reword the first error message.
iSazonov commentedon Sep 27, 2019
Second message "The data is invalid" comes from underlying API. Perhaps we generate a huge query. I found that ReadEvent() returns the error if our query contains number of logs more then 256.
I think the design was ok for Windows XP with 3 logs, perhaps it worked on Windows 7 but it has already lost all meaning - now Windows 10 has over 400 logs and the query is no longer even executed.
I did not find that 256 limit is documented. Nevertheless, we can verify that the filter returns more 256 log names and issue an appropriate message.
iSazonov commentedon Sep 30, 2019
As for "prompt for the -LogName parameter if no parameters is supplied."
Jan Egil Ring (@janegilring) Design is to get snapshot of all events from all logs for a time lot to analyze them. You could open new issue to discuss the design but I do not see the point.
KevinMarquette commentedon Oct 3, 2019
I ran
Get-WinEventwith no parameters and got 1665 errors saying the data is invalid.iSazonov commentedon Oct 3, 2019
Kevin Marquette (@KevinMarquette) See #10648
Robo210 commentedon Nov 25, 2019
Ilya (@iSazonov) In case there is any interest the behavior again in the future, it would probably be best to simply check the event count for each channel and skip adding channels with 0 events to the query. This will cause new events that get logged to one of these empty channels during the query execution to get "missed", but if you consider the design to be to get all the events that were present at the exact moment the user ran the command, this should be fine.
Neither could I, nor could I find any rationale for the limitation in the code. Perhaps a future version of Windows can remove this limit, though you'd still have to deal with older versions that error-out.
The query is actually running hundreds or thousands of times, which is why it prints so many error messages. In fact, I believe every single requested event is being retrieved from the Event Log service, and the error is being printed for every batch of 64 events being retrieved.
The error occurs in readerObj.ReadEvent(), and when the exception is thrown it just continues to the next event.
The exception is getting thrown from the call to GetNextBatch within EventLogReader.ReadEvent. When it gets thrown this.currentIndex is not incremented, so the next call to ReadEvent causes it to retrieve a new batch of events, and so on until the service (which is independently tracking the current index) says there are no more events and GetNextBatch succeeds and sets this.eventCount to 0, causing ReadEvent to gracefully exit with this.isEof == true.
iSazonov commentedon Nov 25, 2019
Kyle Sabo (@Robo210) Thanks!
As soon as we get feedback with a real scenario, we can improve something.
iSazonov commentedon Nov 25, 2019
Kyle Sabo (@Robo210) Thanks!
As soon as we get feedback with a real scenario, we can improve something.