0
0
PowerShellscripting~5 mins

Select-Object for properties in PowerShell - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the <code>Select-Object</code> cmdlet do in PowerShell?
It selects specific properties of an object or set of objects, allowing you to focus on only the data you need.
Click to reveal answer
beginner
How do you select only the Name and Length properties from a list of files using Select-Object?
Use Get-ChildItem | Select-Object Name, Length. This shows just the file names and their sizes.
Click to reveal answer
beginner
What happens if you use Select-Object without specifying any properties?
It returns the whole object with all its properties unchanged.
Click to reveal answer
intermediate
Can Select-Object create new calculated properties? How?
Yes. You can use a hashtable with Name and Expression keys to define a new property based on existing data.
Click to reveal answer
beginner
Why is Select-Object useful when working with large data sets?
It helps reduce clutter by showing only the important properties, making output easier to read and process.
Click to reveal answer
Which command selects only the ProcessName and Id properties from running processes?
AGet-Process | Select-Object ProcessName, Id
BGet-Process | Where-Object ProcessName, Id
CGet-Process | Sort-Object ProcessName, Id
DGet-Process | Format-Table ProcessName, Id
What will Get-ChildItem | Select-Object -First 3 do?
ASelect the first 3 properties of each file
BSelect the first 3 files from the list
CSelect files with size less than 3 bytes
DSelect files with names starting with '3'
How do you add a new property called SizeKB that shows file size in kilobytes using Select-Object?
ASelect-Object Name, @{Name='SizeKB'; Expression={$_.Length / 1KB}}
BSelect-Object Name, SizeKB
CSelect-Object Name, Length * 1024
DSelect-Object Name, Length / 1024
If you want to see all properties of an object, what should you do?
AUse <code>Get-Member</code>
BUse <code>Select-Object</code> with no arguments
CUse <code>Format-List *</code>
DUse <code>Select-Object *</code>
What is the main benefit of using Select-Object in scripts?
ATo filter objects by property values
BTo sort objects alphabetically
CTo reduce output to only needed properties
DTo delete unwanted files
Explain how to use Select-Object to show only certain properties from a list of files.
Think about how you pick only the details you want from a big list.
You got /4 concepts.
    Describe how to create a new calculated property using Select-Object and why it might be useful.
    Imagine adding a new column based on existing data.
    You got /4 concepts.