In Praise of TypeConverters – Spread the Love

PowerShell Team

I just got through reading Scott Hanselman’s blog entry:  TypeConverters: There’s not enough TypeDescripter.GetConverter in which he referenced  Jesse Liberty’s blog entry: Did You Know That… Type Converters allow you to use property attributes in Complex Types and decided to pile on.

Developers – you should stop what you are doing and get TypeConverters in focus.  Here is the big picture way to think about it:  As developers, our mission in life is to make the lives of others easier by providing them the functions they need in they way they need them.  TypeConverters play a huge role in the mission.

TypeConverters are one of the many the unsung heroes behind the magic of PowerShell.  Think about the code you write, think about the code your customers write.  An amazing amount of time and effort goes into coding around impendence mismatches:

  • That API gave me an A but this API needs a B.
  • I can easily get a string but I need an object of type A.

This impendence mismatches cause conceptual and code friction.  Think of TypeConverters as the grease in the object model that make things work together easily.  As a developer, you should take a look at the code you/your customers have to write and consider where a typeconverter could make things easier. 

Traditional languages have the disadvantage of requiring the developer to know about and use the TypeConverter.  The magic of PowerShell is that we do all of that for the user.  We know the TYPE of the data that the user has and we know what TYPE is needed.  We’ll go through lots of hoops to make things "just work" including calling constructors, Parse() methods and TypeConverters.  Abhishek Agrawal wrote a good blog Extending PowerShell with Customer TypeConverters where he describes how to write a TypeConverter and then how to register it with PowerShell so we can use it in our type coercion engine.

Users:  I’d love to hear from you about any examples where you think we should have type convertors and don’t.


Jeffrey Snover [MSFT]
Windows Management Partner Architect
Visit the Windows PowerShell Team blog at:
Visit the Windows PowerShell ScriptCenter at:


Discussion is closed.

Feedback usabilla icon