Main example
List instances
# All instances of LogFileEventConsumer, with the main properties
Get-CimInstance -ClassName LogFileEventConsumer -Namespace 'root/subscription' |
Select-Object -Property Name, Filename, IsUnicode, MachineNameExamples
Filter with WQL
# WQL filter evaluated by the provider: only the instances where IsUnicode is TRUE
$cimParameters = @{
ClassName = 'LogFileEventConsumer'
Namespace = 'root/subscription'
Filter = 'IsUnicode = TRUE'
}
Get-CimInstance @cimParameters |
Select-Object -Property Name, Filename, IsUnicode, MachineNameThe filter is evaluated by the WMI provider: less data is transferred than with Where-Object.
Query a remote computer (CIM session)
review before running# Name of the remote computer
$computerName = 'SERVER01'
# The CIM session (WSMan by default) can be reused for several queries
$cimSession = New-CimSession -ComputerName $computerName
try {
$cimParameters = @{
CimSession = $cimSession
ClassName = 'LogFileEventConsumer'
Namespace = 'root/subscription'
}
Get-CimInstance @cimParameters |
Select-Object -Property Name, Filename, IsUnicode, MachineName
} finally {
Remove-CimSession -CimSession $cimSession
}WSMan (WinRM) is used by default. For a host without WinRM, create the session with -SessionOption (New-CimSessionOption -Protocol Dcom). Add -Credential to use another account.
Show the class structure
# Class structure: properties, types and flags (Key, ReadOnly…)
$cimClass = Get-CimClass -ClassName LogFileEventConsumer -Namespace 'root/subscription'
$cimClass.CimClassProperties |
Select-Object -Property Name, CimType, FlagsProperties
| Name | Type | Access | Description |
|---|---|---|---|
| CreatorSID# | uint8[] | read | Security identifier (SID) that uniquely identifies the user who creates a filter. WMI stores the SID of the user who creates an instance of __EventConsumer or the Administrator SID, depending on the operating system. For more information, see Binding an Event Filter with a Logical Consumer and Monitoring and Responding to Events with Standard Consumers. Code |
| Filename# | string | read | Name of a file that includes the path to which the log entries are appended. If the file does not exist, LogFileEventConsumer attempts to create it. The consumer fails when the path does not exist, or when the user who creates the consumer does not have write permissions for the file or path. Code |
| IsUnicode# | boolean | read | If TRUE, the log file is a Unicode text file. If FALSE, the log file is a multibyte code text file. If the file exists, this property is ignored and the current file setting is used. For example, if IsUnicode is FALSE, but the existing file is a Unicode file, then Unicode is used. If IsUnicode is TRUE, but the file is multibyte code, then multibyte code is used. Code |
| MachineName# | string | read | Name of the computer to which Windows Management Instrumentation (WMI) sends events. Code |
| MaximumFileSize# | uint64 | read | Maximum size of a log file in bytes. If the primary file exceeds its maximum size, the contents are moved to a different file and the primary file is emptied. A value of 0 (zero) means there is no size limit. The default value is 65,535 bytes. The size of the file is checked before a write operation. Therefore, you can have a file that is slightly larger than the specified size limit. The next write operation catches it and starts a new file. The following list identifies the naming structure for the backup file:
For more information about using uint64 values in scripts, see Scripting in WMI. Code |
| MaximumQueueSize# | uint32 | read | Maximum queue for a specific consumer, in bytes. Code |
| Name# key | string | read | Unique name for this consumer. Code |
| Text# | string | read | Standard string template for the text of a log entry. Code |
Remarks
Note: The LogFileEventConsumer does not secure the log file. Therefore, when you configure the LogFileEventConsumer, it is important to specify a directory that is secured to the level that you require.
The LogFileEventConsumer class is derived from the __EventConsumer abstract class.
Inheritance
Superclass chain
- __SystemClass
- __IndicationRelated
- __EventConsumer
- LogFileEventConsumer
Known subclasses
No known subclass.
Requirements
- Namespace
- root/subscription
- Minimum client
- Windows Vista
- Minimum server
- Windows Server 2008
- MOF file
- Wbemcons.mof
- DLL
- Wbemcons.dll
Class qualifiers
AMENDMENT
Microsoft source
Descriptions, properties and methods come from the Microsoft documentation (MicrosoftDocs/win32 repository), published under the CC BY 4.0 licence. Formatting and translations are specific to this site; the PowerShell examples are written for it.