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 Learn
learn.microsoft.com › en-us › powershell › scripting › lang-spec › chapter-04
Types - PowerShell | Microsoft Learn
In PowerShell, this type is System.Management.Automation.PSCustomObject. The cmdlets Import-Module and New-Object can generate an object of this type. The automatic variable $PSCmdlet is an object that represents the cmdlet or function being executed.
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
Variable naming
$Fish = [pscustomobject]@{Name = 'Bob'; Species = 'Carp'} Is better than $MyHashTable = [pscustomobject]@{Name = 'Bob'; Species = 'Carp'} #Store detail of fish Here's a more reputable source with lots of detail if you're interested in the conventions people have settled on- https://github.com/PoshCode/PowerShellPracticeAndStyle/blob/master/Style-Guide/Naming-Conventions.md More on reddit.com
🌐 r/PowerShell
22
16
November 14, 2023
Set-content how write $variable as it is and not as variable
Read this: about_Quoting_Rules . More on reddit.com
🌐 r/PowerShell
9
6
July 8, 2022
Removing the end of a Filename with Powershell

Try changing your Rename-Item to this

Rename-Item -NewName $($_.BaseName -replace ".{4}$")
More on reddit.com
🌐 r/PowerShell
15
18
November 5, 2015
🌐
Microsoft Learn
learn.microsoft.com › en-us › powershell › module › microsoft.powershell.core › about › about_variables
about_Variables - PowerShell | Microsoft Learn
In PowerShell, variables are represented by text strings that begin with a dollar sign ($), such as $a, $process, or $my_var. Variable names aren't case-sensitive, and can include spaces and special characters. But, variable names that include special characters and spaces are difficult to use and should be avoided. For more information, see Variable names that include special characters. There are several different types of variables in PowerShell.
🌐
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 - It wasn’t until I started checking the variable types that I figured out what was going wrong. PowerShell uses dynamic typing, meaning variables can hold values of any type without explicitly declaring the type.
🌐
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
🌐
Wikiversity
en.wikiversity.org › wiki › PowerShell › Variables
PowerShell/Variables - Wikiversity
October 25, 2023 - Use variables to capture user input and use that input later in script output. ... PowerShell data types include integers, floating point values, strings, Booleans, and datetime values.[1] The GetType method returns the current data type of the given variable.[2]
🌐
Microsoft Learn
learn.microsoft.com › en-us › powershell › scripting › lang-spec › chapter-05
Variables - PowerShell | Microsoft Learn
A writable location may be a variable ... of variables: static variables, instance variables, array elements, Hashtable key/value pairs, parameters, ordinary variables, and variables on provider drives....
Find elsewhere
🌐
SS64
ss64.com › ps › syntax-datatypes.html
PowerShell Data Types
Variables and Operators - Create, add, subtract, divide. Enum - Create and use PowerShell enums. [math]::Round - Round a number to any given number of decimal places. DateTime formats Format-Hex - Display a file or other input as hex.
🌐
4sysops
4sysops.com › home › blog › articles › the powershell variable – naming, value, data type
The PowerShell variable – Naming, value, data type
July 28, 2023 - However, if no reasonable way exists to automatically convert the data type, and the data type doesn’t fit with the operation, PowerShell will throw an error. For instance, the lines below will produce the error message “Cannot convert value ‘b’ to type ‘System.Int32.’” ... It is important to note that automatic conversion does not change the variable’s data type. Even though the value of the variable $b in the example has been used as an integer in the calculation, its data type is still String.
🌐
AttuneOps
attuneops.io › attune-hub › powershell-basics-variables-and-data-types
PowerShell Basics: Variables and Data Types - AttuneOps
October 24, 2025 - Automatic variables: These are variables that are created by PowerShell. Their values change as required to maintain their accuracy. Users can't change the value of these variables.
🌐
ShellGeek
shellgeek.com › home › powershell tips › gettype – get variable data type in powershell
GetType - Get Variable Data Type in PowerShell - ShellGeek
April 14, 2024 - In the above PowerShell script example, the $Test variable contains numeric data separated by, (comma). To get data type of variable $Test, use GetType().
🌐
TutorialsPoint
tutorialspoint.com › article › how-to-get-the-variable-data-type-in-powershell
How to get the variable data type in PowerShell?
PowerShell Microsoft Technologies Software & Coding · There are different data types exist for the variable like Byte, Int32, Float, String, etc. To get the variable type, we need to use the GetType() method.
🌐
SharePoint Diary
sharepointdiary.com › sharepoint diary › powershell › powershell variable data types: all you need to know
PowerShell Variable Data Types: All You Need to Know
September 22, 2025 - A variable in PowerShell is denoted by a dollar sign ($) followed by the variable name, and it is not case-sensitive. For instance, you might use $number to store an integer or $message to store a string.
🌐
PsCustom Object
pscustomobject.github.io › powershell › coding habits › powershell best practice › PowerShell-Strongly-Typed-Variables
PowerShell Strongly Typed Variables - PsCustom Object - Hitchikers GUID(e) to Automation
February 2, 2019 - I pride myself on hand-crafting every line of code—no AI shortcuts here! Join me in my journey, where clean, readable code is the norm, and automation is an art form. ... PowerShell is dynamically implicit typed, this is a fact. What does that mean? Unlike other languages, C# or even C/C++, changing a variable’s type won’t generate an error.
🌐
LazyAdmin
lazyadmin.nl › home › how to use powershell variables
How to use PowerShell Variables — LazyAdmin
January 18, 2024 - Preference variables – These variables are also created by PowerShell, but the difference is that you can change these variables to customize the behavior of PowerShell. A good example is the variable $ErrorActionPreference that allows you to set what PowerShell should do when it runs into an error. You can find all the preference variables here. As already briefly covered in the beginning, creating a variable is pretty straightforward. For a simple, loose typed, variable, you only need to specify the variable name.
🌐
MSSQLTips
mssqltips.com › home › powershell variable examples for data types, scope, naming, assignment
PowerShell Variable Examples for Data Types, Scope, Naming, Assignment
February 10, 2022 - See, I’m using PowerShell ISE to code this sample script and run it to see its output, but doing so in that way leaves the contents of the memory intact, in regards to my variables within my script, so the data type stored in memory will be String unless I either specify a data type for each variable declaration, or I close PowerShell ISE, fire it up again and run my script.
🌐
Codecademy
codecademy.com › docs › powershell › variables
PowerShell | Variables | Codecademy
June 8, 2023 - Variables names are not case-sensitive and can include spaces and special characters. The convention is to use only alphanumeric characters and the underscore _ character. PowerShell dynamically assigns a type to a variable depending on the value assigned to it.
🌐
Practical PowerShell
practicalpowershell.com › home › powershell tips › what type? gettype()
What Type? GetType() - Practical PowerShell
June 7, 2020 - There are multiple types of variables. Variables can contain numbers, strings and more. Sometimes this can be key to how we handle the data on the variable or how we can display or search for information in the variable. First we will take a look at Get-Date. Get-Date pulls your current date and time information from your computer. We can store this information in a variable and then see how that data is being stored/interpreted by PowerShell: Notice that the type is ‘DateTime’ which is logical considering what could pulled from Get-Date.
🌐
PowerShell Test-Path
powershellfaqs.com › powershell-get-variable-type
How to Get the Type of a Variable in PowerShell?
September 6, 2024 - In this example, we assign the string value “New York” to the variable $usaCity. By appending .GetType().Name to the variable, PowerShell returns the type of the variable, which is “String” in this case.
🌐
EDUCBA
educba.com › home › data science › data science tutorials › powershell tutorial › powershell variables
PowerShell Variables | How to Declare and Initialize PowerShell Variables?
March 22, 2023 - Variables in PowerShell are automatic ... a data type, for example, if it is $age=1 than it will be int32 and if It is $student =” Ranjan” than it will be a string. Variable in PowerShell starts with $ symbol.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai