PowerShell Basics Level: Beginner Chapter 3: Think in Objects, Not Text
Objects
An object is a structured value with properties and methods. Learning to inspect an object is the skill that makes the rest of PowerShell make sense.
Lesson 5 of 7 in Chapter 3: Think in Objects, Not Text. Previous step in this path: Other command chaining. 3 learning objectives, 6 examples, and a knowledge check.
Start: what you will learn
An object is a structured value with properties and methods. Learning to inspect an object is the skill that makes the rest of PowerShell make sense.
Learning objectives
- Define an object, a property, and a method
- Inspect any object with Get-Member
- Pick a property with dot notation
Concept in simple words
What it is: An object is a structured value that carries facts, called properties, and actions, called methods. A property describes the object, and a method is something the object can do. For example, a service object has a Name property that tells you its name, a Status property that tells you whether it is running, and methods that act on that service, while a string object has a Length property that tells you how many characters it holds, and methods that change or inspect its text.
Why it works
Why it exists: Admin work is full of things that have many facts at once, such as a service with a name, a status, and a display name, or a process with a name, an id, and a CPU value. An object keeps those facts together under clear names, so you can ask for exactly one fact, filter by one fact, and sort by one fact, without guessing which part of a text line holds that fact.
Why it works this way: PowerShell is built on .NET, which is a framework for building software, and .NET organises values as objects. Because a command returns objects rather than plain text, the facts stay attached to each result, and later commands can read exactly the fact they need. The type of an object, shown by Get-Member as TypeName, decides which properties and methods that object offers, so two different types can offer different facts and actions, even when they look similar on screen.
Think of it like this
Think of it like this: An object is like a person file in an office. The file has facts written on it, such as a name and an id, and those are properties. It also has actions you can ask for, such as print or close, and those are like methods. Text output would be like a photocopy of the file, where you can read it but you cannot ask it to do anything, and you cannot ask it for one named fact without reading the whole page.
How it works, step by step
How it works, step by step: First, run a command and look at its output as rows in a table, where each row is one object. Then, to learn what an object offers, pipe the command into Get-Member, which lists its properties and methods, with their types, which tell you what kind of value each one holds. Get-Member also shows the TypeName at the top, which tells you the exact kind of object you are dealing with.
How it works, step by step, continued: Next, pick one property from that list and read it with dot notation, which means a dot followed by the property name, for example $process.Name. If you try to read a property straight from a command result, wrap the command in parentheses first, such as (Get-Date).DayOfWeek, so PowerShell reads the property from the result, not from the command name. Without the parentheses, PowerShell tries to read a property from the command itself, which does not work.
What Get-Member shows, in detail: Get-Member lists members, which is the general word for properties, methods, and other kinds of members, sorted alphabetically, with methods listed first, followed by properties. Each row shows the member name, its MemberType, such as Property, Method, or AliasProperty, and a Definition that shows the type or the action signature. An AliasProperty is a second name for another property, such as Name being an alias for ServiceName on a service object, so both names give you the same value.
How to narrow Get-Member: When a full Get-Member list is long, narrow it with -MemberType, such as Get-Member -MemberType Property to see only properties, or Get-Member -MemberType Method to see only methods. You can also narrow by name, such as Get-Member -Name Name, Id, to check only the members you care about. Narrowing is useful when you already know roughly what you need, and you want to confirm the exact spelling and type before you use it.
How the displayed table differs from the object: The table you see on screen is only a view, chosen by PowerShell formatting, and it does not show every property. Many properties are hidden from the default table, even though they are still present on the object and still usable in a filter, a sort, or a Select-Object. So never assume that a property does not exist just because it is not in the table, and never guess a property name from a table heading alone, because the heading can hide the exact property name.
How dot notation chains: Dot notation can chain, so you can read a property of a property, such as $today.Year, where $today holds a date object and Year is a property of that date object. You can also read a property from a method result, or call a method on a property value, but keep chains short while you are learning, because a long chain is hard to debug when one link in the middle returns nothing.
How methods differ from properties: A property is read with dot notation and no parentheses, such as $text.Length, while a method is called with dot notation plus parentheses, such as $text.ToUpper(), even when the method takes no arguments. If you write $text.ToUpper without parentheses, PowerShell shows you information about the method itself, rather than running it and giving you the upper case text. That missing pair of parentheses is a common and confusing mistake, because the output looks like a result but it is not the text you wanted.
How method arguments work: Some methods take arguments, which are values inside the parentheses, in a fixed order. For example, "PowerShell".Substring(0, 4) takes a start position and a length, and returns the first four characters, Powe. The numbers here are zero based, like array indexes, so position 0 is the first character. Always check Get-Member for the method definition, because it shows what arguments the method expects and what type it returns.
How string methods behave: String methods such as ToUpper(), ToLower(), and Trim() return a new string, and they do not change the original string, because strings in .NET are immutable, which means they cannot be changed in place. So $text = "powershell"; $text.ToUpper() shows POWERSHELL, but $text still holds powershell afterwards, unless you store the result back with $text = $text.ToUpper(). This is the same read, change, store back pattern you met in the variables lesson.
How property values can be objects too: A property value is not always simple text or a number, it can itself be an object with its own properties. For example, a process object has a StartTime property that holds a date object, so you can read $process.StartTime.Year to get the year it started. When a property value looks like a complex value rather than a simple word, treat it as an object in its own right, and inspect it with Get-Member if you need to know what it offers.
Why it works
Why a missing property gives an empty result: If you read a property name that does not exist on an object, PowerShell returns nothing, rather than an error, in most everyday cases. That empty result is easy to misread as meaning there was nothing to find, when the real problem was a misspelled or guessed property name. Always confirm a property name with Get-Member before you trust an empty result, and check the spelling, including capital letters, even though PowerShell member names are usually case insensitive.
What GetType tells you: Every object has a GetType() method, which returns information about its type, such as ("PowerShell").GetType().Name, which gives String. Knowing the type helps you when two objects look alike but behave differently, because the type decides which methods are available. Use GetType when a method you expected is missing, because you may be holding a different type than you assumed.
When to use it
When to use it, and when not to: Use Get-Member whenever you meet a new command, before you guess a property name, because a close guess gives an empty result, not an error, and empty results are easy to misread. Do not guess property names from the table headings alone, because the displayed heading can hide the exact property name. Do not run a destructive method, such as Kill on a process object, while you are learning, because methods can change state, and a method that looks harmless in a list may stop a process or close a service.
Common mistakes, in plain words: The most common mistake is guessing a property name instead of checking Get-Member, and then trusting an empty result. Another is forgetting the parentheses around a command when you read a property straight from its output, such as Get-Date.DayOfWeek, which does not work. A third is calling a method without parentheses, and then wondering why you got method information instead of a result. A fourth is assuming the table shows every property, when many properties are hidden from the default view. A fifth is reading a property without parentheses, such as .Length without a dot and a name, or confusing a property with a method, so Length needs no parentheses while ToUpper needs them.
How to spot an object problem: If a property read gives you nothing, run Get-Member and check the exact spelling. If a method call gives you method information instead of a value, add parentheses. If a table looks too narrow, use Get-Member or Select-Object with a star, such as Select-Object *, to see more properties, while remembering that a star in Select-Object returns objects with all properties, which can be a lot to read. If a value changes unexpectedly, check whether a method changed state, or whether you stored a new object when you meant to store a property value.
Worked examples
Read each example in order. Each one explains its parts, then shows what to look for in the output.
Syntax
Get-Command | Get-MemberExample 1
Lists the properties and methods of process objects, with types.
Get-Process | Get-MemberIllustrative output: TypeName: System.Diagnostics.Process Name MemberType ---- ---------- Name Property Id Property Kill Method
Example 2
Stores one process object, then reads its Name property with dot notation.
$p = Get-Process | Select-Object -First 1
$p.NameIllustrative output: pwsh
Example 3
A string, which is text in quotes, is also an object, and Length is one of its properties. The parentheses group the string first, then .Length reads the Length property, which counts the characters. PowerShell has 10 letters, so the answer is 10, and this shows that dot notation works on simple values too, not only on process or service objects.
("PowerShell").LengthIllustrative output: 10
Example 4
ToUpper is a method, so it needs parentheses to run. The method returns a new string in upper case, POWERSHELL, and it does not change the original string, because strings are immutable. Without the parentheses, you would see information about the method instead of the upper case text.
("powershell").ToUpper()Illustrative output: POWERSHELL
Example 5
This narrows Get-Member to only properties, and only the two named members, Name and Id. Use this pattern when a full Get-Member list is too long, and you want to confirm the exact spelling and type of the properties you plan to use, before you write a filter or a Select-Object step.
Get-Process | Select-Object -First 1 | Get-Member -MemberType Property -Name Name, IdIllustrative output: Name MemberType ---- ---------- Name Property Id Property
Example 6
The first line stores a date object. The second line reads its Year property with dot notation, and the third line reads its DayOfWeek property. Both properties belong to the same date object, and the day value depends on the date when you run the command, so treat the day in the output as an example for one date, not as a fixed answer.
$today = Get-Date
$today.Year
$today.DayOfWeekIllustrative output: 2026 Tuesday
Nothing on this page executes PowerShell code. The outputs above are illustrative only.
Diagram
Choose a stage above to see what it does.
Common mistakes and troubleshooting
Read these before you try the examples, so you can spot the same problems in your own work.
- Guessing a property name instead of checking Get-Member. A close guess gives an empty result, not an error.
- Forgetting the parentheses around a command when you read a property straight from its output, such as Get-Date.DayOfWeek, which does not work.
- Guessing a property name instead of checking Get-Member, and then trusting an empty result as if it meant there was nothing to find.
- Calling a method without parentheses, such as $text.ToUpper, and then wondering why you got method information instead of the upper case text.
- Assuming the displayed table shows every property, when many properties are hidden from the default view. Use Get-Member to see the full list.
- Running a destructive method, such as Kill on a process object, while you are still learning. Read the method name in Get-Member, but do not run state changing methods on real processes until you understand what they do.
Knowledge check
Knowledge check
What does Get-Member show you?
Pick one answer. Feedback appears right away, and you can try again.
Remember this and next step
Remember this: A property is a fact, a method is an action, Get-Member shows both with their types and the TypeName, dot notation reads one property, parentheses group a command result before you read a property from it, properties need no parentheses while methods need parentheses even with no arguments, the displayed table is only a view and hides many properties, a guessed property name gives an empty result rather than an error, and string methods return a new string without changing the original.
Next step: Custom objects