Get-Event - PowerShell command help and examples

Gets the events in the event queue. (Get-Event)


NAME
Get-Event
SYNOPSIS
Gets the events in the event queue.
SYNTAX
Get-Event [-EventIdentifier] <int> [<CommonParameters>] Get-Event [[-SourceIdentifier] <string>] [<CommonParameters>]
DESCRIPTION
The Get-Event cmdlet gets events in the Windows PowerShell event queue for the current session. You can get all events or use the EventIdentifier or SourceIdentifier parameters to specify the events. When an event occurs, it is added to the event queue. The event queue includes events for which you have registered, events created by using the New-Event cmdlet, and the event that is raised when Windows PowerShell exits. You can use Get-Event or Wait-Event to get the events. This cmdlet does not get events from the Event Viewer logs. To get those events, use Get-WinEvent or Get-EventLog.
PARAMETERS
-EventIdentifier <int> Gets only the events with the specified event identifier. Required? true Position? 1 Default value Accept pipeline input? true (ByPropertyName) Accept wildcard characters? false -SourceIdentifier <string> Gets only events with the specified source identifier. The default is all events in the event queue. Wildcards are not permitted. Required? false Position? 1 Default value All events Accept pipeline input? true (ByPropertyName) Accept wildcard characters? false <CommonParameters> This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer and OutVariable. For more information, type, "get-help about_commonparameters".
INPUTS
None You cannot pipe input to this cmdlet.
OUTPUTS
System.Management.Automation.PSEventArgs Get-Event returns a PSEventArgs object for each event. To see a description of this object, type "get-help get-event -full" and see the Notes section of the help topic.
NOTES
Events, event subscriptions, and the event queue exist only in the current session. If you close the current session, the event queue is discarded and the event subscription is canceled. The Get-Event cmdlet returns a PSEventArgs object (System.Management.Automation.PSEventArgs) with the following properties. -- ComputerName: The name of the computer on which the event occurred. This property value is populated only when the event is forwarded from a remote computer. -- RunspaceId: A GUID that uniquely identifies the session in which the event occurred. This property value is populated only when the event is forwarded from a remote computer. -- EventIdentifier: An integer (Int32) that uniquely identifies the event notification in the current session. -- Sender: The object that generated the event. In the value of the Action parameter, the $Sender automatic variable contains the sender object. -- SourceEventArgs: The first parameter that derives from EventArgs, if it exists. For example, in a timer elapsed event in which the signature has the form "Object sender, Timers.ElapsedEventArgs e", the SourceEventArgs property would contain the Timers.ElapsedEventArgs. In the value of the Action parameter, the $SourceEventArgs automatic variable contains this value. -- SourceArgs: All parameters of the original event signature. For a standard event signature, $args[0] represents the sender, and $args[1] represents the SourceEventArgs. In the value of the Action parameter, the $SourceArgs automatic variable contains this value. -- SourceIdentifier: A string that identifies the event subscription. In the value of the Action parameter, the SourceIdentifier property of the $Event automatic variable contains this value. -- TimeGenerated: A DateTime object that represents the time at which the event was generated. In the value of the Action parameter, the TimeGenerated property of the $Event automatic variable contains this value. --MessageData: Data associated with the event subscription. Users specify this data when they register an event. In the value of the Action parameter, the MessageData property of the $Event automatic variable contains this value.

Examples

EXAMPLE 1
C:\PS>get-event
Description
----------- This command gets all events in the event queue.
EXAMPLE 2
C:\PS>get-event -sourceIdentifier "PowerShell.ProcessCreated"
Description
----------- This command gets events in which the value of the SourceIdentifier property is "PowerShell.ProcessCreated".
EXAMPLE 3
C:\PS>$events = get-event C:\PS> $events[0] | format-list -property * ComputerName : RunspaceId : c2153740-256d-46c0-a57c-b805917d1b7b EventIdentifier : 1 Sender : System.Management.ManagementEventWatcher SourceEventArgs : System.Management.EventArrivedEventArgs SourceArgs : {System.Management.ManagementEventWatcher, System.Management.EventArrivedEventArgs} SourceIdentifier : ProcessStarted TimeGenerated : 11/13/2008 12:09:32 PM MessageData : C:\PS> get-event | where {$_.TimeGenerated -ge "11/13/2008 12:15:00 PM"} ComputerName : RunspaceId : c2153740-256d-46c0-a57c-b8059325d1a0 EventIdentifier : 1 Sender : System.Management.ManagementEventWatcher SourceEventArgs : System.Management.EventArrivedEventArgs SourceArgs : {System.Management.ManagementEventWatcher, System.Management.EventArrivedEventArgs} SourceIdentifier : ProcessStarted TimeGenerated : 11/13/2008 12:15:00 PM MessageData :
Description
----------- This example shows how to get events by using properties other than SourceIdentifier. The first command gets all events in the event queue and saves them in the $events variable. The second command uses array notation to get the first (0-index) event in the array in the $events variable. The command uses a pipeline operator (|) to send the event to the Format-List command, which displays all properties of the event in a list. This allows you to examine the properties of the event object. The third command shows how to use the Where-Object cmdlet to get an event based on the time that it was generated.
EXAMPLE 4
C:\PS>get-event -eventIdentifier 2
Description
----------- This command gets the event with an event identifier of 2. RELATED LINKS Online version: http://go.microsoft.com/fwlink/?LinkID=113453 Register-ObjectEvent Register-EngineEvent Register-WmiEvent Unregister-Event New-Event Remove-Event Wait-Event C:\Windows>powershell get-help Remove-Event -full

Microsoft Windows [Version 10.0.19045.3693]
Copyright (c) 2023 Microsoft Corporation.

ColorConsole [Version 3.7.1000] PowerShell 2.0-Export

Windows 11, 10, 8.1, 8, 7 / Server 2022, 2019, 2016











Windows-10


... Windows 10 FAQ
... Windows 10 How To


Windows 10 How To


... Windows 11 How To
... Windows 10 FAQ



PowerShell: Gets the events in the event queue.

HTTP: ... PS_Windows/en/Get-Event.htm
0.046
11824

Can i manually create in Windows 10 and 8.1 a restore point?

Where can I find the file version history in Windows 8.1 / 10 (backup, security)!

How big should be the Windows 8.1 / 8.0 and disk partition size?

Font View and Compare-Tool on Windows 11!

Enlargement in Internet Explorer 11/10 (zoom, font)!

Automatisches Wiederholen von YouTube-Videos als Schleife!



(0)