Bird
0
0

What does the Add-Member -MemberType ScriptMethod cmdlet do in PowerShell?

easy📝 Conceptual Q11 of 15
PowerShell - Working with Objects
What does the Add-Member -MemberType ScriptMethod cmdlet do in PowerShell?
ADeletes a property from an object
BAdds a custom method (function) to an existing object
CCreates a new object from scratch
DConverts an object to a string
Step-by-Step Solution
Solution:
  1. Step 1: Understand Add-Member usage

    Add-Member is used to add properties or methods to existing objects in PowerShell.
  2. Step 2: Focus on ScriptMethod type

    When -MemberType ScriptMethod is used, it adds a method (a function) that can be called on the object.
  3. Final Answer:

    Adds a custom method (function) to an existing object -> Option B
  4. Quick Check:

    Add-Member ScriptMethod = Adds method [OK]
Quick Trick: ScriptMethod adds functions to objects, not properties [OK]
Common Mistakes:
  • Confusing ScriptMethod with adding properties
  • Thinking it creates new objects
  • Assuming it deletes object members

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes