about_eventlogs

TOPIC
    about_eventlogs

SHORT DESCRIPTION
    Windows PowerShell creates a Windows event log that is
    named “Windows PowerShell” to record Windows PowerShell events. You can
    view this log in Event Viewer or by using cmdlets that get events, such as
    the Get-EventLog cmdlet. By default, Windows PowerShell engine and provider
    events are recorded in the event log, but you can use the event log
    preference Variables to customize the event log. For example, you can add
    events about Windows PowerShell commands.

LONG DESCRIPTION
    The Windows PowerShell event log records details of Windows PowerShell
    operations, such as starting and stopping the program engine and starting
    and stopping the Windows PowerShell providers. You can also log details
    about Windows PowerShell commands.

    In Windows Vista and later versions, the Windows PowerShell event log
    is in the Application and Services Logs group. The Windows PowerShell log
    is a classic event log that does not use the Windows Eventing technology.
    To view the log, use the cmdlets designed for classic event logs, such as
    Get-EventLog.

Viewing the Windows PowerShell Event Log

     You can view the Windows PowerShell event log in Event Viewer or by
     using the Get-EventLog and Get-WmiObject cmdlets. To view the contents
     of the Windows PowerShell log, type:

     Get-Eventlog -logname “Windows PowerShell”

     To examine the events and their properties, use the Sort-Object cmdlet,
     the Group-Object cmdlet, and the cmdlets that contain the Format verb
     (the Format cmdlets).

     For example, to view the events in the log grouped by the event ID, type:

     Get-Eventlog “Windows PowerShell” | Format-Table -groupby eventid

     Or, type:

     Get-Eventlog “Windows PowerShell” | Sort-Object eventid `
            | Group-Object eventid

     To view all the classic event logs, type:

     Get-Eventlog -list

     You can also use the Get-WmiObject cmdlet to use the event-related
     Windows Management Instumentation (WMI) classes to examine the event log.
     For example, to view all the properties of the event log file, type:

     Get-WmiObject win32_nteventlogfile | where `
            {$_.logfilename -eq “Windows PowerShell”} | Format-List -property *

     To find the Win32 event-related WMI classes, type:

    Get-WmiObject -list | where {$_.name -like “win32*event*”}

     For more information, type “Get-Help Get-Eventlog” and
     “Get-Help Get-WmiObject“.

Selecting Events for the Windows PowerShell Event Log

     You can use the event log preference Variables to determine which events
     are recorded in the Windows PowerShell event log.

     There are six event log preference Variables; two Variables for each of
     the three logging components: the engine (the Windows PowerShell
     program), the providers, and the commands. The LifeCycleEvent Variables
     log normal starting and stopping events. The Health Variables log error
     events.

     The following table lists the event log preference Variables.

         Variable                     Description
         ————————– —————————————-

     $LogEngineLifeCycleEvent     Logs starting and stopping of
                                     Windows PowerShell.

     $LogEngineHealthEvent        Logs Windows PowerShell program errors.

     $LogProviderLifeCycleEvent Logs starting and stopping of
                                     Windows PowerShell providers.

     $LogProviderHealthEvent     Logs Windows PowerShell provider errors.

     $LogCommandLifeCycleEvent    Logs starting and completion of commands.

     $LogCommandHealthEvent     Logs command errors.

     (For information about Windows PowerShell providers,
     type: “Get-Help about_providers“.)

     By default, only the following event types are enabled:

     $LogEngineLifeCycleEvent
     $LogEngineHealthEvent
     $LogProviderLifeCycleEvent
     $LogProviderHealthEvent

     To enable an event type, set the preference Variable for that event type
     to $true. For example, to enable command life-cycle events, type:

     $LogCommandLifeCycleEvent

     Or, type:

     $LogCommandLifeCycleEvent = $true

     To disable an event type, set the preference Variable for that event type
     to $false. For example, to disable command life-cycle events, type:

     $LogProviderLifeCycleEvent = $false

     The Variable settings apply only for the current Windows PowerShell
     session. To apply them to all Windows PowerShell sessions, add them to
     your Windows PowerShell profile.

Security and Auditing

     The Windows PowerShell event log is designed to indicate activity and
     to provide operational details for troubleshooting.

     However, like most Windows-based application event logs, the
     Windows PowerShell event log is not designed to be secure. It should not
     be used to audit security or to record confidential or proprietary
     information.

     Event logs are designed to be read and understood by users. Users can
     read from and write to the log. A malicious user could read an event log
     on a local or remote computer, record false data, and then prevent the
     logging of their activities.

SEE ALSO
    Get-EventLog
    Get-WmiObject
    about_preference_variables