Working with events
Events are a staple of .NET developers looking to react to changes of an object, for example. A .NET class mimicking a coffee machine, for instance, would raise an event coffee dispensed whenever a coffee is ordered. We can react to three kinds of events in PowerShell, as well:
Cmdlet | Event description |
| Events of .NET objects, for instance, the exited event of a |
| Events of WMI classes, for instance, an event that is raised whenever a new process starts |
| Events of the PowerShell engine, for instance, an event triggered when PowerShell is closing |
We will have a look at all three kinds of events through practical examples.
Object events
As we mentioned, object events are the bread and butter of developers, but that doesn't mean that operations people shouldn't be using them. One such event that is quite useful in an enterprise scenario is an event log subscription. In a running PowerShell session,...