Scott Hanselman described how to “spot-weld” new properties on existing types using the types.ps1xml file. When writing your own Cmdlets this might not be the best way to modify the objects you return. In this post I’m going into how to change existing types in code using ETS Properties based on a SharpSvn/Subversion cmdlet. A common use-case would be to fix a function that returns a string instead of a FileInfo or Uri instance (that can be passed along the pipeline).
The main trick is not to return the plain object, but a PSObject wrapping the plain object. The PSObject allows you to add and remove custom properties and methods from C# code.
Continue reading ‘PowerShell Cmdlets - adding/overriding members’
