Everything Is an Object
A file knows its name, size and date; so does everything else PowerShell shows you.
Updated
Objects
- What an Object Is: Get-Member (Apprentice): Everything PowerShell shows you is an object, a thing that carries named facts called properties, the way a library book's card carries its title, author and due date, and Get-Member lists every fact an object knows.
- Properties and Methods (Apprentice): A dot after an object reads one of its properties, such as a file's Length or LastWriteTime, and a dot with parentheses runs one of its methods, something the object can do, such as ToUpper() or AddDays(-7).
Choosing What to Show
- Picking Columns: Select-Object (Apprentice): Select-Object keeps only the properties you name with -Property, only the first or last few objects with -First and -Last, and with -ExpandProperty hands you one property's plain values, ready to save as a list.
- Tables and Lists: Format-Table and Format-List (Apprentice): PowerShell shows each kind of object with a saved view of a few properties, Format-Table and Format-List show the ones you choose as a table or a list, Format-List * shows every one, and a Format- command goes last because what comes out of it is for the screen, not for other commands.
Exercise: What a File Knows
- Exercise: What a File Knows (Apprentice): Answer a friend's questions about their trip photos by asking the objects themselves, with Get-Member, properties, methods and Select-Object, save a plain list and a table of sizes, and let a Pester check tell you what's done.