Welcome to this addition of the PowerShell ABC's where you'll find 26 posts detailing a component of the PowerShell scripting language, one letter at a time. For today's letter is the letter "S", I will discuss PowerShell's extension of existing object with Synthetic Members.
A powerful feature in PowerShell is it's ability to extend existing object types and instances. In doing so, it can overlay a common set of interfaces onto an existing source of data.
This is different that the traditional method of sub-classing or creating types derived from other types in other object-oriented programming languages where you would extend a type by creating an entirely new type. In PowerShell you can add members to existing types and objects without having to create new types to do so.
These objects that you can add to existing objects are referred to as Synthetic Members since they are not natively part of the existing object. PowerShell makes use of this ability to dynamically add members to objects for adaptation and extension. This allows you to work with two different objects much the same way.
In the provider infrastructure, this becomes useful in that it allows you to write scripts that are independent of the type of object that the provider produces. By adding common attributes such as PSIsContainer and PSPath, you'll have a common way to access whether a provider object is a directory and the physical file system path that object represents.
The Add-Member Cmdlet can be used to add these dynamic members to an object. The syntax for the Add-Member Cmdlet is as follows: