Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a custom object with a Name property set to 'Alice'.
PowerShell
$person = [PSCustomObject]@{ Name = [1] } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the string value.
Using the property name instead of the value.
✗ Incorrect
The Name property value must be a string, so it needs quotes like 'Alice'.
2fill in blank
mediumComplete the code to add an Age property with value 30 to the custom object.
PowerShell
$person = [PSCustomObject]@{ Name = 'Bob'; Age = [1] } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting numbers inside quotes making them strings.
Using the property name instead of the value.
✗ Incorrect
Age is a number, so it should be written without quotes as 30.
3fill in blank
hardFix the error in the code to correctly create a custom object with City property 'Seattle'.
PowerShell
$location = [PSCustomObject]@{ City = [1] } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving the string without quotes causing an error.
Using the property name instead of the value.
✗ Incorrect
String values must be enclosed in quotes, so 'Seattle' is correct.
4fill in blank
hardFill both blanks to create a custom object with properties Name and Score set to 'Eve' and 95.
PowerShell
$result = [PSCustomObject]@{ Name = [1]; Score = [2] } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting numbers inside quotes.
Using property names instead of values.
✗ Incorrect
Name needs a quoted string 'Eve', Score needs the number 95 without quotes.
5fill in blank
hardFill all three blanks to create a custom object with properties FirstName, LastName, and Age set to 'John', 'Doe', and 40.
PowerShell
$person = [PSCustomObject]@{ FirstName = [1]; LastName = [2]; Age = [3] } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using double quotes inconsistently.
Putting numbers inside quotes.
Using property names instead of values.
✗ Incorrect
FirstName and LastName are strings needing quotes, Age is a number without quotes.