PowerShell: Object Type, Properties, Methods
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.
- A command may output multiple objects.
- Each object has a type.
- The number of objects and type depends on the command parameter. For example,
dir -name
may return many objects but all of typeSystem.String
, butdir
may return many objects, some of typeSystem.IO.FileInfo
, some of typeSystem.IO.DirectoryInfo
.

help dir
, showing types of its input and output.

help dir
output, showing the types of paramater args.
Find the Types of Command Output
To find the object types of a command's output, pipe it to Get-Member
(alias gm
).
For each object type, Get-Member
shows it only once in its output.
examples:
"abc" | Get-Member # System.String

dir | Get-Member # System.IO.DirectoryInfo, System.IO.FileInfo
Get-Date | Get-Member # System.DateTime
Get the Type of an Object
List Properties of a Given Object Type
dir -file | Get-Member -MemberType Properties

List Methods of a Given Object Type
dir -file | Get-Member -MemberType Method

Show Property Values of a Object
Show all properties and their values of a object
Get-Date | select -Property *
dir -file | select -First 1 | select -Property *
select
is alias ofSelect-Object
