Select-Object for properties
📖 Scenario: You are working with a list of files in a folder. Each file has many details like name, length, creation time, and more. You want to see only the file names and their sizes to keep things simple.
🎯 Goal: Build a PowerShell script that gets files from a folder and shows only the Name and Length properties using Select-Object.
📋 What You'll Learn
Create a variable called
files that stores the list of files from the current directory using Get-ChildItem.Create a variable called
properties that holds the list of properties Name and Length.Use
Select-Object with the properties variable to select only those properties from files and store the result in selectedFiles.Print the
selectedFiles variable to show the output.💡 Why This Matters
🌍 Real World
When managing files on your computer, you often want to see only important details like file names and sizes instead of all information.
💼 Career
IT professionals and system administrators use PowerShell scripts like this to quickly gather and report file information for maintenance and audits.
Progress0 / 4 steps