Bird
0
0

Which of the following is the correct syntax to add a NoteProperty named Age with value 30 to an existing object $person?

easy📝 Syntax Q12 of 15
PowerShell - Working with Objects
Which of the following is the correct syntax to add a NoteProperty named Age with value 30 to an existing object $person?
AAdd-Member -Object $person -Type NoteProperty -Property Age -Value 30
BAdd-Member -InputObject $person -MemberType NoteProperty -Property Age -Value 30
CAdd-Member -InputObject $person -MemberType Property -Name Age -Value 30
DAdd-Member -InputObject $person -MemberType NoteProperty -Name Age -Value 30
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct parameter names

    The correct parameters for Add-Member are -InputObject, -MemberType, -Name, and -Value.
  2. Step 2: Check member type and property name

    NoteProperty is the correct member type for adding simple properties. The property name is specified with -Name.
  3. Final Answer:

    Add-Member -InputObject $person -MemberType NoteProperty -Name Age -Value 30 -> Option D
  4. Quick Check:

    Correct syntax uses -InputObject, -MemberType, -Name, -Value [OK]
Quick Trick: Use -InputObject, -MemberType NoteProperty, -Name, and -Value [OK]
Common Mistakes:
  • Using -Object instead of -InputObject
  • Using -Property instead of -Name
  • Using MemberType Property instead of NoteProperty

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes