PowerShell: Get Object Type

By Xah Lee. Date: . Last updated: .

Get Object's Type

To get a object type programatically, use .getType() method.

# String

# System.String

if you have a collection of objects, pipe it to foreach.

# see all types of a collection
Get-ChildItem | ForEach-Object {$_.getType().fullname}
# System.IO.DirectoryInfo or System.IO.FileInfo

Find the Types of Command Output, Interactively

"abc" | Get-Member
# System.String
dir | Get-Member
# System.IO.DirectoryInfo, System.IO.FileInfo
Get-Date | Get-Member
# System.DateTime
PowerShell get member 2024-03-10
PowerShell get member 2024-03-10

PowerShell: Object and Type