Investigating PowerShell Command Results

by Jan 25, 2023

When you run into new PowerShell commands, it’s always a good idea to get familiar with the result objects. When you simply run a PowerShell command in the console, the console does not show all available properties by default.

One good way of investigating command results is to use Select-Object to show all properties of the first (random) returned object. Here is an example:

Get-Service | Select-Object -Property * -First 1

This way, you get one result object with all of its properties visible, and you can see real-world data contained in these properties to better evaluate what particular properties are for.

Another way of investigating is to use Get-Member and view all available properties from a more technical/declarative perspective:

Get-Service | Get-Member -MemberType *property

Here, you can see the returned data types, and each property is declared as “{get;}” (readonly) or “{get;set;}” (read/writeable).


Tweet this Tip! Tweet this Tip!