Everything is an object
Inspect objects with Get-Member, use their properties and methods, and build your own.
- Inspect an object’s type, properties and methods with Get-Member
- Read properties and call methods with dot notation
- Create custom objects with [pscustomobject]
In a text shell, ls -l prints lines and you cut out the column you want. In PowerShell, Get-ChildItem returns objects. What you see on screen is just a view PowerShell drew for you; the objects underneath carry much more.
Every object has:
- a type, like
System.String,System.DateTimeorSystem.IO.FileInfo - properties - data you read (and sometimes set):
.Length,.Year,.Name - methods - actions you call with parentheses:
.ToUpper(),.AddDays(7)
Get-Member (alias gm) lists them all. Pipe anything into it.
1$name = 'Ember'
2$name.GetType().FullName
3$name.Length
4$name.ToUpper()
5$name.Replace('E', 'A')
6$name | Get-Member -MemberType Property | ForEach-Object Name
7$hatched = Get-Date -Year 2026 -Month 3 -Day 14
8$hatched.DayOfWeek
9$hatched.AddDays(100).ToString('yyyy-MM-dd')System.String 5 EMBER Amber Length Saturday 2026-06-22
A few rules of dot notation:
- Wrap a command in parentheses to use its result:
(Get-Date).Year. - Methods always need parentheses, even with no arguments:
.ToUpper(). Leave them off and PowerShell shows you the method’s definition instead of calling it. - Dot into a whole array and PowerShell collects that property from every item (member enumeration):
(Get-ChildItem).Namegives every name.
Try it
Property or method?
Sort each member by kind. Hint: methods do something and need parentheses.
“'Ember'.Length”
“'Ember'.ToUpper()”
“(Get-Date).DayOfWeek”
“(Get-Date).AddDays(7)”
“$file.LastWriteTime”
“'a,b'.Split(',')”
“$list.Count”
Your own objects: [pscustomobject]
You can make objects too. Write a hashtable of property names and values, and put [pscustomobject] in front. The result behaves like any built-in object: dot into it, sort it, filter it, export it. A list of them prints as a table.
1$ember = [pscustomobject]@{ Name = 'Ember'; Species = 'Firedrake'; Wingspan = 12 }
2$glim = [pscustomobject]@{ Name = 'Glim'; Species = 'Wisp'; Wingspan = 2 }
3"$($ember.Name) spans $($ember.Wingspan) m"
4$ember.Wingspan + $glim.Wingspan
5$ember, $glimEmber spans 12 m 14 Name Species Wingspan ---- ------- -------- Ember Firedrake 12 Glim Wisp 2
Notice "$($ember.Name)": inside double quotes, a plain $ember.Name would expand only $ember and then print .Name literally. The subexpression $( ... ) runs the whole thing first. You’ll use it constantly.
Key takeaways
Commands return objects; the screen shows only a formatted view of them.
Get-Memberlists an object’s type, properties and methods.Use
.Propertyand.Method(); wrap commands in parentheses:(Get-Date).Year.[pscustomobject]@{ ... }builds your own objects; use"$($obj.Prop)"inside strings.
Lesson quiz
7 questions · pass with 5 correct · up to 50 XP
Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.
Practice: write PowerShell scripts
Write a script in the editor and run it for real against sample input, which is piped into your script as $input. Scripts run on PowerShell 6.2 through Try It Online (tio.run), a free public service, so these exercises avoid PowerShell 7-only syntax; your script and test input are sent there.
Dragon name badges
Each input line is a dragon’s name. Print a badge for each: the name in capitals, then the number of letters in parentheses, like EMBER (5 letters). Use the string’s methods and properties.
- Three dragons
- One dragon
Lessons teach PowerShell 7; your script runs on PowerShell 6.2 via Try It Online (tio.run), a free public service, so stick to syntax that works there. Test input is piped into your script as $input. Your script and test input are sent to that service.
Check-up dates
Each input line is a hatching date like 2026-03-14. Dragons need a check-up 100 days after hatching. Print hatched 2026-03-14 (Saturday), check-up 2026-06-22 (Monday) for each.
Turn the text into a date with [datetime]$line, then use .AddDays(), .ToString('yyyy-MM-dd') and .DayOfWeek.
- Spring hatchlings
- Winter hatchling
Lessons teach PowerShell 7; your script runs on PowerShell 6.2 via Try It Online (tio.run), a free public service, so stick to syntax that works there. Test input is piped into your script as $input. Your script and test input are sent to that service.
Questions about this lesson
Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.
Loading posts…