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
The script selects device objects rather than projecting the displayName property, so it returns full records, not a names-only output. It tempts because device names are the obvious field to inspect, and adding a Select-Object displayName projection would be correct when a names-only listing is required.
- ✓
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
The script queries Intune managed devices, not the Autopilot device identity collection, so it cannot list Autopilot-registered devices. It tempts because both surfaces describe Windows hardware, and querying the Autopilot device identities endpoint would be correct when auditing which devices are registered for Autopilot deployment.
- ✗
To update the enrollment type of all Windows devices.
Why it's wrong here
The script filters and reads device objects; it issues no update or patch call, so no enrollment type changes. It tempts because Autopilot and enrollment data appear in device records, and such a script would be correct if it invoked an update on the enrollment configuration rather than only querying devices.
Go deeper
Related to this question
Learn chapter
Managing Microsoft 365 Apps and Office Updates
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 — 556 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.