Mass Spectrometry of PowerShell Objects

For many people working with Windows PowerShell, the shell can sometimes transmute into an unknown maze of twisty little passages. Whether you’re an end user, technician, administrator, or developer, take a deep breath – there are a few simple tools and tactics which might help.

One technique which can shed some light into those twisty little passages is a lovely cmdlet called Get-Member. If you’ve been in a PowerShell class or read the PowerShell team blogs, you’ve probably heard this referred to as one of the “four pillars of discoverability.” Yet as with spelunking, shedding a little light tends to reveal more scary and vast unknown depths. In other words, the tools used to make sense of things can quite possibly make things more confusing initially. For example, here is a question someone recently emailed to me.

“In Windows PowerShell, I have been working with the Get-Member cmdlet. I have seen the following values for MemberType: Method, NoteProperty, ParameterizedProperty, Property, ScriptProperty, PropertySet, ScriptMethod, AliasProperty, and Event. What do they mean?”


There is hope. We needn’t delve into mass spectrometry to analyze PowerShell objects – they are luckily far simpler than molecular structure.

As Get-Member can reveal, PowerShell objects do typically have both properties and methods. If you’re familiar with true object-oriented programming languages, PowerShell’s properties and methods aren’t insanely different. If you have no clue what properties and methods are, here’s a brief synopsis.

A property is an aspect, a characteristic, and attribute, a data value of a object. For example, if you have an interactive host session, it’s user interface has a foreground color and a background color. These ForegroundColor and BackgroundColor are properties – just two data values which are attributes of the raw user interface of a console host session. Looking at $host.UI.RawUI.ForegroundColor shows an example of such a property value. The results from Get-WMIObject Win32_Volume can reveal Capacity and FreeSpace properties (among many others) of disk storage volumes.

A method is an interface to ask an object to do something. Invoking a method is like running a program – but sometimes on a more microscopic level – you’re requesting the object to do something specific. For example, one of the methods on a WMI Win32_Volume object is the DefragAnalysis() method which allows checking the fragmentation of the allocation units in the volume. Other methods can be used to perform the actual defragmentation, format the volume, mount it, create a mount point, or check the structure of the volume.

Different kinds (classes) of objects have different properties and methods. Furthermore, even different objects of the same type (class) will have different values for their properties and distinct resultant behaviors via their methods. That’s the basics. Now, back to the question. When using Get-Member, different kinds of properties and methods may be revealed. Here’s a quick synopsis of some of their meanings:

  • Property – a basic property that is a part of the .NET object, and not PowerShell specific
  • Properties – basic .NET properties as well as all other types of properties described below
  • PropertySet – property sets are collections of properties which are predefined, such as PSConfiguration on a process
  • AliasProperty – a shorthand notation for another property, such as WS as an AliasProperty for WorkingSet
  • CodeProperty – a .NET property for the class of the object rather than a distinct property per instance
  • NoteProperty – a PowerShell addition to an object which extends beyond the .NET properties
  • ParameterizedProperty – a property that takes parameter values and calculates a result, like a ScriptProperty
  • ScriptProperty – some PowerShell script code for “get” and “set” (read/write) access to a calculated property
  • MemberSet – a predefined set of properties and methods
  • Method – a basic .NET method for the object, which is not PowerShell specific
  • Methods – all basic, code, and script methods
  • CodeMethod – a class method which isn’t specific to the instances of that class
  • ScriptMethod – a PowerShell addition which runs some script code when invoked
  • Event – when action are performed on the object or its state changes, the defined event can be sent

These brief synopses don’t get into the full capabilities, but hopefully can start you on the right path to not being so overwhelmed by the possible kinds properties and methods.

Certainly, if you have questions on a specific type of object member or the ramifications of distinctions between .NET and script properties or methods, don’t hesitate to ask.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.