PowerShell: Object Type, Properties, Methods

By Xah Lee. Date: . Last updated: .

PowerShell commands input (parameter args) and output are all .NET objects. Each .NET object has a type, and members (“member” means properties and methods.). It's critical to understand this to master PowerShell.

Find a Object's Type

To find the object type of a command's output, pipe it to Get-Member. For each object type, Get-Member shows it only once in its output.

Some examples to try:

"abc" | gm
# System.String
dir | gm
# System.IO.DirectoryInfo, System.IO.FileInfo
Get-Date | gm
# System.DateTime

List Properties of a Given Object Type

dir -file | gm -MemberType Properties

List Methods of a Given Object Type

dir -file | gm -MemberType Method

Show Property Values of a Object

Show all properties and their values of a output object

Get-Date | select -Property *
dir -file | select -First 1 | select -Property *

Screenshot Examples

Screenshot 2021-09-09 205739 zH7S7
help dir output, showing the types of paramater args.
PowerShell help dir 2021-05-25 ZY62f
help dir, showing types of its input and output.
PowerShell date properties 20210525142244
date object's properties
PowerShell date methods 2021-09-09
date object's methods
PowerShell date properties 20210525141338
property values of a specific date object




Script Examples