Bird
0
0

What will be the result of running this PowerShell snippet?

medium📝 Command Output Q5 of 15
PowerShell - Active Directory
What will be the result of running this PowerShell snippet?
$users = Get-ADUser -Filter *
$count = $users.Count
Write-Output $count
AThe total number of AD users in the domain
BAn error because $users is not an array
CThe string '*', not a number
DZero, because no users are retrieved
Step-by-Step Solution
Solution:
  1. Step 1: Understand Get-ADUser -Filter *

    This command retrieves all AD users as an array.
  2. Step 2: Count the users and output

    $users.Count gives the number of users, Write-Output prints it.
  3. Final Answer:

    The total number of AD users in the domain -> Option A
  4. Quick Check:

    Get all users and count = total users [OK]
Quick Trick: Use .Count to get number of objects in array [OK]
Common Mistakes:
  • Assuming $users is a single object
  • Expecting error from .Count on collection
  • Thinking filter * returns string

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes