The Incredible Extensible PSObject
summary
PowerShell objects accept live extension: use $obj.psobject.Members.Add (fastest with false) or Add-Member for single instances, and persist behaviors across a type with Update-TypeData vs types.ps1xml (types.ps1xml loads faster and prevents redefinition; Update-TypeData is debuggable). Examples include casting hashtables to PSCustomObject or ConvertFrom-Json, adding a script property that converts Markdown to HTML, giving ints a Double method, and creating a shapeshifting “man‑bear‑pig” by inserting and clearing PSTypeNames — all of which execute interactively.
AI-written summary · about
chapters (10)
- 0:00Introduction
- 1:16PowerShell objects are amazing
- 2:41Stretching PSObject instances
- 5:13Pseudo objects in PowerShell
- 8:47Decorating with PSTypeNames
- 12:00Extending types and pseudo types
- 15:14Extending Markdown example
- 20:02Shape-shifting objects
- 23:14Man bear pig shape-shifting
- 27:44Why use extensible PSObjects & Q&A
related talks
48mThe road to extensibility
45mInteractive Enhancements to PowerShell
48mUnexplained phenomena: powerful tricks you likely didn't know were even possible
01h 16mLevel Up Your PowerShell: Essential Tips, Tricks, and Techniques
51mDon't do that, do this instead: PowerShell worst practices and..
47mThink Abstract, abstracting your PowerShell code
01h 37mMore Game Breaking PowerShell
01h 32mOptimizing Visual Studio Code for PowerShell, 2023 Edition
