0
0
PowerShellscripting~10 mins

Custom objects (PSCustomObject) in PowerShell - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
AName
BAlice
C"Alice"
D'Alice'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the string value.
Using the property name instead of the value.
2fill in blank
medium

Complete 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'
A'30'
B30
C"30"
DAge
Attempts:
3 left
💡 Hint
Common Mistakes
Putting numbers inside quotes making them strings.
Using the property name instead of the value.
3fill in blank
hard

Fix 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'
ASeattle
BCity
C'Seattle'
D"Seattle"
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving the string without quotes causing an error.
Using the property name instead of the value.
4fill in blank
hard

Fill 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'
A'Eve'
B95
C"Eve"
DScore
Attempts:
3 left
💡 Hint
Common Mistakes
Putting numbers inside quotes.
Using property names instead of values.
5fill in blank
hard

Fill 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'
A'John'
B'Doe'
C40
D"John"
Attempts:
3 left
💡 Hint
Common Mistakes
Using double quotes inconsistently.
Putting numbers inside quotes.
Using property names instead of values.