First of all, you lack parentheses to call GetType. What you see is the MethodInfo describing the GetType method on [DayOfWeek]. To actually call GetType, you should do:

$a.GetType();
$b.GetType();

You should see that $a is a [DayOfWeek], and $b is a custom object generated by the Select-Object cmdlet to capture only the DayOfWeek property of a data object. Hence, it's an object with a DayOfWeek property only:

C:\> $b.DayOfWeek -eq $a
True
Answer from Cédric Rup on Stack Overflow
🌐
Microsoft
devblogs.microsoft.com › dev blogs › scripting blog [archived] › powertip: find the type of an object
PowerTip: Find the Type of an Object - Scripting Blog [archived]
November 6, 2013 - How can I use Windows PowerShell to easily find the type of object that is stored in a variable? Use the GetType method (which all objects have): PS C:> $date = get-date PS C:> $date.GetType() IsPublic IsSerial Name […]
Discussions

Powershell and Types
Get-member will be your friend. The type is typically at the top of the output. It will also output methods and properties of the variable//output that is being referenced. More on reddit.com
🌐 r/PowerShell
32
11
August 28, 2024
How to inspect a powershell object (specifically an array, I think)?
In that order you take each item and pipe into Get-Member, so Get-Member gives you type information of each item in the array. To get array info you write Get-Member -InputObject $bytes If I type $bytes. and then tab-complete, I find options such as Insert, Length, CompareTo, Contains, etc Arrays are a special case in powershell (and .NET) Because your $bytes variable is of type [array], those are the fields and properties of all arrays in powershell. int[] byte[] anything[] are all of type [array]. You don't really need to "discover" those with get-member, precisely because you can just tab-complete. They'll never change no matter whether you have a byte array, a fileinfo array, or whatever else. What will change are the types of objects within the array, and those can have different properties, and that's what Get-Member will tell you about. Powershell gives you the type information of the items within the array. So dir | get-member will give you System.IO.DirectoryInfo and System.IO.FileInfo types. More on reddit.com
🌐 r/PowerShell
8
15
February 13, 2021
Conditional to check type of object?
Hey, you can just use the -eq operator: $a[0].GetType() -eq [System.Management.Automation.ParameterAttribute] Best regarrs! More on reddit.com
🌐 r/PowerShell
4
2
February 6, 2020
Invoke-WebRequest - How can I pass xml string as Request body?
Have you set it as the $body variable? If you use @' to open and '@ to close, the string can be multiline. More on reddit.com
🌐 r/PowerShell
8
3
May 5, 2015
🌐
Xah Lee
xahlee.info › powershell › powershell_get_type.html
PowerShell: Get Object Type
To get a object type programatically, use .getType() method. "abc".getType().name # String "abc".getType().fullname # System.String · if you have a collection of objects, pipe it to foreach.
🌐
Blogger
mctexpert.blogspot.com › 2016 › 03 › diving-in-deep-with-gettype.html
Diving in deep with GetType()
March 22, 2016 - Good question. This one took a little bit of research. I first had to figure out the object type that was giving me this information. PS C:\> Get-Member -InputObject (Get-Date).GetType()
🌐
Computerworld
computerworld.com › home › data center
PowerShell objects: A tutorial – Computerworld
August 6, 2015 - In PowerShell, it is a simple matter to see an object’s properties and methods: Just use the Get-Member cmdlet to view them. You can do this by piping the output of a cmdlet. Remember that output is an object to the Get-Member cmdlet, like ...
🌐
Reddit
reddit.com › r/powershell › powershell and types
r/PowerShell on Reddit: Powershell and Types
August 28, 2024 -

Once upon a time I was a C/C++ programmer. I am trying to get my feet wet with PS to accomplish some maintenance tasks on my computer that might not justify either a command line or Windows app. The lack of typing in PS is really messing with my head. It seems as though variables can be created as any type and that "functions" in PS can return a wide variety of types.

How am I supposed to know what is in a variable if I cannot trace it back to its declaration and see a type?

Example question...

$filenames = Get-ChildItem -Path "D:\Brian's Stuff\Media\Data\Video\Santa Barbara\0001 - 0100\Santa Barbara 8493" -Filter *.mp4

So apparently this invocation of Get-ChildItem returns a collection. How do I know the collection type (is it an array? A linked list? An abstraction of a binary tree?) And what about the type of object being stored in the collection. How do I determine that without any variable typing? $filenames is a collection, but of what? And it all can change depending on what type of information I am asking Get-ChildItem for?

Maybe I need to find a strongly typed language. I don't get it. BTW I am literally 6 hours old with PS. Just started. Trying to learn only what I need to learn to get the job done. Don't intend to study the language out of intellectual curiousity.

Top answer
1 of 5
14
Get-member will be your friend. The type is typically at the top of the output. It will also output methods and properties of the variable//output that is being referenced.
2 of 5
12
So apparently this invocation of Get-ChildItem returns a collection. Get-ChildItem does not return a collection. It emits scalar (single) objects to the pipeline in a continuous stream. This applies to most cmdlets. If output is captured to a variable (like in your example), PowerShell will internally collect each emitted object. Upon completion, the resultant variable's value and type is dependent on the number of objects emitted. If no objects are emitted, the variable's value is AutomationNull, which represents nothing in PowerShell. It is not $null, which differs from "nothing". If one object is emitted, the variable's value is the object of whichever object type was emitted. If multiple objects are emitted, the variable's value is a collection of type [object[]] (an array), containing each object emitted. In your example, Get-ChildItem may emit [IO.FileInfo] and/or [IO.DirectoryInfo] instances or nothing depending on what type of item (if any) is found. You could limit the results to files only by specifying the -File parameter. Reflection can be performed with the GetType() method. $fileNames.GetType().FullName will give you the full type name, which you can lookup using the .NET API browser (providing the type is from Microsoft). Get-Member is another valuable tool to aid object exploration. $array = 1, 2, 3 $array | Get-Member # Get instance members of the array's elements $array | Get-Member -Static # Static members only Get-Member -InputObject $array # Instance members of the array itself Further reading: about_Objects about_Properties about_Methods Chapter 3 - Discovering objects, properties, and methods Viewing object structure
🌐
SharePoint Diary
sharepointdiary.com › sharepoint diary › powershell › how to get the variable type in powershell?
How to Get the Variable Type in PowerShell? - SharePoint Diary
September 22, 2025 - The primary method for checking the type of a variable in PowerShell is the GetType() method. This method is available on all PowerShell objects and returns an instance of the System.Type class, which provides detailed information about the ...
Find elsewhere
🌐
PowerShell is fun
powershellisfun.com › 2024 › 04 › 11 › powershell-data-reference-types-for-varriables
PowerShell is fun :)PowerShell data/reference types for variables
April 11, 2024 - Using “.GetType()” behind the variable will show that the BaseType is System.Object with a String type. This is something that I use to compare versions of applications or PowerShell modules.
🌐
Local Host
locall.host › home › powershell › unlocking the secrets: how to effortlessly determine the type of a powershell variable
Unlocking the Secrets: How to Effortlessly Determine the Type of a PowerShell Variable
August 10, 2023 - # Step 2: The Secret Ingredient – The GetType() Method · The key to determining a variable’s type lies in the `.GetType()` method. Available for all objects in PowerShell, this method returns vital information concerning the variable’s type.
🌐
PDQ
pdq.com › powershell › select-object
Select-Object - PowerShell Command | PDQ
This parameter was introduced in Windows PowerShell 3.0. ... This cmdlet supports the common parameters: Verbose, Debug,ErrorAction, ErrorVariable, WarningAction, WarningVariable,OutBuffer, PipelineVariable, and OutVariable. ... You can pipe any object to Select-Object . ... This command creates objects that have the Name, ID, and working set (WS) properties of process objects. Select objects by property and format the results: PS C:\> Get-Process Explorer | Select-Object -Property ProcessName -ExpandProperty Modules | Format-List ProcessName : 00THotkey Size : 256 Company : TOSHIBA Corporation FileVersion : 1, 0, 0, 27 ProductVersion : 6, 2, 0, 0 Description : THotkey Product : TOSHIBA THotkey ModuleName : 00THotkey.exe FileName : C:\WINDOWS\system32\00THotkey.exe BaseAddress : 4194304
🌐
Dell
dell.com › support › contents › en-us › article › product-support › self-support-knowledgebase › locate-service-tag › notebook
Locate Your Laptop's Service Tag | Dell US
Search for PowerShell in the Start menu and open the app as administrator. Type Get-WmiObject win32_bios | Select-Object SerialNumber and press Enter.
🌐
GitHub
github.com › MicrosoftDocs › PowerShell-Docs › blob › main › reference › 7.5 › Microsoft.PowerShell.Utility › Get-TypeData.md
PowerShell-Docs/reference/7.5/Microsoft.PowerShell.Utility/Get-TypeData.md at main · MicrosoftDocs/PowerShell-Docs
This includes type data that was added to the session by Types.ps1xml file and dynamic type data that was added by using the parameter of the Update-TypeData cmdlet. You can use the extended type data that Get-TypeData returns to examine the type data in the session and send it to the Update-TypeData and Remove-TypeData cmdlets. Extended type data adds properties and methods to objects in PowerShell.
Author   MicrosoftDocs
🌐
Practical PowerShell
practicalpowershell.com › home › powershell tips › what type? gettype()
What Type? GetType() - Practical PowerShell
June 7, 2020 - We then use the ‘.GetType()’ to see what variable type is set with this data storage. Notice that the type of variable we have now is a very specific ‘SmtpAddress”. What does that mean exactly? Now, what if we wanted to store all email addresses for a mailbox. The value for that is ‘EmailAddresses’: Notice that we have a different type (name and base type) for this object’s properties.
🌐
Typer
typer.tiangolo.com
Typer
And there are tools to create groups of subcommands, add metadata, extra validation, etc. You get: great editor support, including completion and type checks everywhere. Your users get: automatic --help, auto-completion in their terminal (Bash, Zsh, Fish, PowerShell) when they install your ...
🌐
SQL Studies
sqlstudies.com › 2019 › 10 › 28 › powershellbasics-the-gettype-and-gettypecode-methods
#PowershellBasics: The GetType() and GetTypeCode() methods | SQL Studies
October 28, 2019 - I’m not 100% certain what all of the types available are but it looks like they are the .NET types with the option to create more. ... #Create/set variables $IntVar = 1 $IntArrayVar = 1,2,3 $StringVar = "Test" $StringArrayVar = "Test","MoreTest" #GetType() Demo $IntVar.GetType() $IntArrayVar[0].GetType() $IntArrayVar.GetType() $StringVar.GetType() $StringArrayVar[0].GetType() $StringArrayVar.GetType()
🌐
Microsoft Learn
learn.microsoft.com › en-us › powershell › module › microsoft.powershell.utility › select-object
Select-Object (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Learn
When you use Select-Object with the First or Index parameters in a command pipeline, PowerShell stops the command that generates the objects as soon as the selected number of objects is reached. To turn off this optimizing behavior, use the Wait parameter. This example creates objects that have the Name, Id, and working set (WS) properties of process objects. Get-Process | Select-Object -Property ProcessName, Id, WS
🌐
LazyAdmin
lazyadmin.nl › home › how to use powershell select-object
How to use PowerShell Select-Object — LazyAdmin
August 29, 2023 - Let’s start with the basics and we will dive deeper into to abilities of PowerShell Select-Object along the way. To simply select a couple of properties from an object we can use a comma-separated list with the property’s names: Get-Process | Select-Object -Property Name, CPU # You can ...
🌐
Microsoft Certified Professional Magazine
mcpmag.com › articles › 2017 › 06 › 01 › working-with-object-types-in-powershell.aspx
Working with Object Types in PowerShell -- Microsoft Certified Professional Magazine Online
June 1, 2017 - The other technique is to make use of the –as operator to convert an object from one type to another. ... If you have ever worked with Read-Host, you may have found that the data being returned is always a string regardless of what was typed at the prompt, such as a date or number. The trick to enforcing the data is to use a type operator to enforce the expected type. [datetime]$Date = Read-Host 'Enter a date (dd/mm/yyyy)' $Date.GetType().Fullname
🌐
AttuneOps
attuneops.io › attune-hub › powershell-basics-variables-and-data-types
PowerShell Basics: Variables and Data Types - AttuneOps
October 24, 2025 - # This is a print to screen CMDLET [Write-Host]. Write-Output "FirstHashTable has above below and Data Type of $DataTypeHastableOne" $FirstHashTable `n # This Variable "SecondHashTable" is of datatype System.Object ("data type = Object or HashTable") New-Variable -Name "SecondHashTable" -Value @{ ID = 05; Name = "LINUX" } # Gets the Datatype and assigns it to the Variable $DataTypeHastableTwo $DataTypeHastableTwo = (($SecondHashTable).GetType()).Name # Pause the script for 1 Seconds Start-Sleep -s 1 # `n - it creates a new line after the message.