Advanced PowerShell Eventing Scripting Techniques
summary
Claims that PowerShell lacks a full scripting environment inside event handler scriptblocks and offers concrete workarounds: uses WMI intrinsic/extrinsic events, Win32_ModuleTrace logging to capture DLL loads (writes to file/event log), timers and engine idle events, delegates like ServerCertificateValidationCallback override to accept bad certs, and async/unmanaged callbacks to emulate a simple web server. Explains a reflection-only assembly resolve hack that sets a nonpublic field to attach a handler. Demonstrations work but require hacks: globals, files, or wrapper Register/Get/Unregister commands to persist or retrieve objects.
AI-written summary · about
chapters (13)
- 0:00Start
- 2:33Types of Events Intrinsic and Extrinsic Events an Intrinsic Event
- 4:55Instance Creation Event
- 6:47Engine Events
- 7:59Register Object Event
- 13:18Event Handler
- 16:44Module Auditing
- 20:07Delegates
- 22:33Unmanaged Callbacks
- 23:20Dotnet Asynchronous Callbacks
- 29:48Limitations
- 36:26Global Variables
- 38:24Unregister Event
related talks
47mEvent-Driven Automation with PowerShell: Listening for Change, Acting in Real Time
48mMastering PowerShell Parameters: Advanced Techniques and Best Practices
01h 07mPowerShell: Designed for a Messy World
01h 11mWorkshop - Automating for DevOps
26mPowerShell Oddities & Curiosities: Language Quirks You Forgot (or Never Knew)
46mPowerShell as an MCP Tooling Host: Using MCPServerPS to Supercharge AI-Assisted...
01h 29mModularizing PowerShell: Making Code Portable
01h 03mThe Zen of Powershell - PowerShell for the C# dev
