Recall & Review
beginner
What is an object array in PowerShell?
An object array in PowerShell is a collection that holds multiple objects, allowing you to store and manage several items together in one variable.
Click to reveal answer
beginner
How do you create an empty object array in PowerShell?
You create an empty object array by assigning an empty array literal:
$array = @().Click to reveal answer
beginner
How can you add an object to an existing array in PowerShell?
You can add an object by using the += operator, like
$array += $newObject. This appends the new object to the array.Click to reveal answer
intermediate
What is the difference between an array and an object array in PowerShell?
An array can hold any type of data, but an object array specifically holds objects, which can have properties and methods, making them more versatile.
Click to reveal answer
beginner
How do you access the properties of objects inside an object array?
You access properties by indexing the array and then using dot notation, for example:
$array[0].PropertyName.Click to reveal answer
How do you initialize an empty object array in PowerShell?
✗ Incorrect
In PowerShell,
@() creates an empty array. Curly braces {} are for script blocks, square brackets [] are for type literals, and parentheses () are for grouping.Which operator adds an object to an existing array in PowerShell?
✗ Incorrect
The
+= operator appends an item to an array in PowerShell.How do you access the first object's property named 'Name' in an object array called $arr?
✗ Incorrect
Use index first, then dot notation:
$arr[0].Name.What type of elements can an object array hold in PowerShell?
✗ Incorrect
Object arrays can hold any objects, including custom objects with properties.
What happens if you add an object to an array using += in PowerShell?
✗ Incorrect
Using
+= appends the new object to the existing array.Explain how to create and add objects to an object array in PowerShell.
Think about starting empty and then adding items one by one.
You got /3 concepts.
Describe how to access properties of objects stored inside an object array.
Remember arrays use numbers to pick items, objects use names for properties.
You got /3 concepts.