MD-102 Get-MgDevice Practice Question
Exhibit
Refer to the exhibit.
$devices = Get-MgDeviceManagementManagedDevice -Filter "operatingSystem eq 'Windows'"
foreach ($device in $devices) {
if ($device.deviceEnrollmentType -eq 'windowsAzureADJoin') {
Write-Output $device.id
}
}Refer to the exhibit. An administrator runs this Graph PowerShell script. What is the purpose?
⚠ Common exam trap
Test-takers frequently confuse DeviceId (the Entra ID object ID) with the device name or Autopilot registration, leading candidates to select options about listing names or Autopilot devices instead of device IDs.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
To list the IDs of Windows devices.
The script uses Get-MgDevice with a filter for operatingSystem eq 'Windows' to retrieve all Windows device objects from Microsoft Entra ID, regardless of their join type (joined, registered, or hybrid). By selecting the DeviceId property, it outputs the unique identifiers of these devices. The DeviceId is the Entra ID object identifier, not the device name or Autopilot registration status.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
To output the device names of all Windows devices.
Why it's wrong here
Incorrect. The script selects `DeviceId`, not device name. To get device names, you would select `DisplayName`.
- ✓
To list the IDs of Windows devices.
Why this is correct
Correct. The script lists the unique IDs (`DeviceId`) of all Windows devices in Microsoft Entra ID. While the option says 'joined', the script does not filter by join type; it returns all Windows devices in the directory.
- ✗
To list devices that are registered in Autopilot.
Why it's wrong here
Incorrect. The script does not filter for Autopilot devices. To list Autopilot devices, you would use `Get-MgDeviceManagementWindowsAutopilotDeviceIdentity`.
- ✗
To update the enrollment type of all Windows devices.
Why it's wrong here
Incorrect. The script only retrieves data; it does not perform any update operation.
Go deeper
Related to this question
Learn chapter
Introduction to Endpoint Management in Microsoft 365
Key term
Autopilot
Autopilot is a Microsoft cloud-based deployment technology that automates the setup and configuration of new Windows devices, reducing manual IT effort and enabling users to be productive from the first boot.
Key term
Microsoft Entra ID
Microsoft Entra ID is a cloud-based identity and access management service that lets employees sign in and access resources both inside and outside of your organization.
About these practice questions
Courseiva writes every MD-102 question from scratch — 942 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This MD-102 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the MD-102 exam.