Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,14 @@ private string BuildStructuredQuery(EventLogSession eventLogSession)

Comment thread
iSazonov marked this conversation as resolved.
Resolved
case "GetLogSet":
{
const int WindowsEventLogAPILimit = 256;
if (_logNamesMatchingWildcard.Count > WindowsEventLogAPILimit)
Comment thread
SteveL-MSFT marked this conversation as resolved.
Resolved
{
string msg = _resourceMgr.GetString("LogCountLimitExceeded");
Exception exc = new Exception(string.Format(CultureInfo.InvariantCulture, msg, _logNamesMatchingWildcard.Count, WindowsEventLogAPILimit));
ThrowTerminatingError(new ErrorRecord(exc, "LogCountLimitExceeded", ErrorCategory.LimitsExceeded, null));
}

result.Append(queryListOpen);
uint queryId = 0;
foreach (string log in _logNamesMatchingWildcard)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,5 +282,7 @@ The defined template is following:
<data name="Counter1FileLimit" xml:space="preserve">
<value>You cannot import more than one comma-separated (.csv) or tab-separated (.tsv) performance counter file in each command.</value>
</data>

<data name="LogCountLimitExceeded" xml:space="preserve">
<value>Log count ({0}) is exceeded Windows Event Log API limit ({1}). Adjust filter to return less log names.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ Describe 'Get-WinEvent' -Tags "CI" {
$results = get-winevent -logname $providerForTests.LogLinks.LogName -MaxEvents 10
$results | Should -Not -BeNullOrEmpty
}
It 'Throw if count of lognames exceeds Windows API limit' {
if ([System.Environment]::OSVersion.Version.Major -ge 10) {
{ get-winevent -logname * } | Should -Throw -ErrorId "LogCountLimitExceeded,Microsoft.PowerShell.Commands.GetWinEventCommand"
}
}
It 'Get-WinEvent can use the simplest of filters' {
$filter = @{ ProviderName = $providerForTests.Name }
$testEvents = Get-WinEvent -filterhashtable $filter
Expand Down