PowerShell: Get Object Type

By Xah Lee. Date: .

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

"abc".getType().ToString()
# "System.String"
PowerShell getType 2022-04-28
getType()

if you have potentially multiple objects, pipe it to foreach.

dir | ForEach-Object {$_.getType().ToString()}
# System.IO.DirectoryInfo or System.IO.FileInfo
Get-Date | ForEach-Object {$_.getType().ToString()}
# System.DateTime

PowerShell: Value Types

PowerShell

Practical How-To

list files

list dirs

on dir

on file

Windows config

zip tar

misc


PowerShell in Depth

Programing PowerShell

Value Types

String

Variable

Boolean

Conditional

Data Structure

Loop and Iteration

Input/Output

Function

Profile and Script

Script Examples