In a previous tip, we have added a new script method to a string called Words() which would split the string into words. But is it worth the effort? After all, your new Words() method would only be available in that single instance of a string. You would have to manually add the method to every string where you wanted to use it.
As it turns out, you can teach PowerShell to add members to object types by default. This is done by the Extended Type System (ETS). To add the Words() method to every single string, launch Notepad and enter this:
Save it as "myExtension.ps1xml", and then load it into the PowerShell ETS:
Immediately, every new string created automatically has a new method called Words():
The two places to look at in your XML template are the type name (here: System.String) that you want to append and inside the Tag ScriptMethod, the name and script code of your new method.
Updates to the ETS are temporary and only apply to the current session. You may want to add your call to Update-TypeDate to one of your profile scripts so the extension is loaded automatically when you launch PowerShell.