Understanding formatting
Let’s think about our old friend, Get-Process
. We know that when we run it, it displays a list of the running processes on our machine. For each process, it displays some of the properties. We know from running Get-Process | Get-Member
that there are many more that it doesn’t display unless we ask for them explicitly. This is the case for pretty much every PowerShell cmdlet; the output we see is rarely the complete output of every property the objects in the pipeline possess. How does that happen? Welcome to the default format.
PowerShell decides on the format for displaying output based on the TypeName
of the object in the pipeline. If the TypeName
has an associated default formatting view, then PowerShell will use it. If there isn’t a default formatting view, for instance, if it is a PSCustomObject
, then the shell will determine whether there is a default property set and, if so, display that. If there are fewer than five default properties...