Bird
0
0

What will be the output of this PowerShell code?

medium📝 Command Output Q4 of 15
PowerShell - Cross-Platform PowerShell
What will be the output of this PowerShell code?
$response = Invoke-RestMethod -Uri 'https://jsonplaceholder.typicode.com/users/1'
$response.email
A"1"
B"Leanne Graham"
C"Bret"
D"Sincere@april.biz"
Step-by-Step Solution
Solution:
  1. Step 1: Understand the API endpoint

    The URL 'https://jsonplaceholder.typicode.com/users/1' returns JSON data for user with ID 1, including fields like name, username, email, etc.
  2. Step 2: Access the 'email' property

    The code accesses the 'email' property of the response object, which corresponds to the user's email address.
  3. Final Answer:

    "Sincere@april.biz" -> Option D
  4. Quick Check:

    Check the JSON response for user 1's email [OK]
Quick Trick: Invoke-RestMethod returns parsed JSON objects [OK]
Common Mistakes:
  • Confusing 'email' with 'name' or 'username'
  • Expecting raw JSON string instead of parsed object
  • Using incorrect property names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes