Skip to the main content.

ScriptRunner Blog

Handling Events with PowerShell and .NET (Part 1)

Table of Contents

Post Featured Image

The Oxford dictionary defines an event as “a thing that happens, especially something important”. In the computing world most people associate events with logging, however events go beyond that. In fact, a log is nothing but an output from an event.

This blog post covers two types of events, PowerShell Engine Events and .NET Object Events (click here for part 2 of the series, Handling events with PowerShell and WMI). 

Keep on reading if you want to learn how to handle both PowerShell Engine Events and .NET Object Events and which PowerShell commandlets will get you there.

The Basics: From PowerShell Classes and Objects to Events

Before we delve into the details of PowerShell events, we first need to understand classes and objects.
  • A class is a collection of properties and methods.
  • An object is an instance of the class which is being used to access properties and methods.

Simple, right? Let’s simplify this using a real-world example.

I’m an object of my parents class. My parents have certain properties such as black hair, brown eyes etc. and certain methods such as cooking, dancing etc.

Let’s take a simple example of a class defined in PowerShell:

class PrintName
          
        

Related posts

3 min read

ScriptRunner now available in the Microsoft Azure Marketplace

6 min read

Managing Microsoft Exchange with PowerShell

2 min read

VMUG Webcast: Mastering VMware Management with PowerCLI

About the author: