Our Thinking / Field Notes / The Guide

STEP-BY-STEP GUIDANCE / MICROSOFT GRAPH POWERSHELL SDK FOR READ-ONLY MICROSOFT INTUNE REPORTING

Export Intune Devices and Policies with Microsoft Graph PowerShell

Sign in with two read-only Graph scopes, export enrolled devices, configuration profiles, compliance policies and settings catalog policies to CSV and JSON, and learn how paging, throttling and v1.0 versus beta affect the results.

Start here

Use the Microsoft Graph PowerShell SDK with an interactive sign-in and request only two read-only scopes: DeviceManagementManagedDevices.Read.All for enrolled devices and DeviceManagementConfiguration.Read.All for policies. Sign in as someone who holds a read-only Intune role, because the scopes alone do not decide what you can see. The v1.0 cmdlets list devices, configuration profiles and compliance policies, but settings catalog policies currently need a beta call. Export everything to CSV and JSON, and compare snapshots before you write a single change.

Why report before you automate

Most Intune scripting stories start with someone wanting to change something in bulk. That is the wrong end to begin from. A read-only export tells you what is actually in the tenant, gives you a dated snapshot to compare against later and exercises the awkward parts of Graph - permissions, paging, throttling, beta endpoints - while nothing can go wrong in the tenant itself.

This article builds a small, secret-free toolkit using the Microsoft Graph PowerShell SDK. You sign in interactively as yourself, request only read scopes, and produce four files: a device inventory and a policy inventory, each as CSV for people and JSON for scripts. At the end there is a short comparison script that shows what changed between two exports. Nothing here creates, edits, assigns or deletes anything in Intune.

What you need before you start

The list is short, but each item can stop the whole exercise if it is missing.

  • An Intune-licensed tenant. Microsoft states that the Intune APIs in Microsoft Graph require an active Intune licence for the tenant.
  • PowerShell 7 or later. Microsoft recommends it for the Graph SDK on all platforms. Windows PowerShell 5.1 can work, but needs .NET Framework 4.7.2 or later, an up-to-date PowerShellGet and an execution policy of RemoteSigned or less restrictive.
  • An account that can read Intune. The Intune built-in Read Only Operator role is the natural fit: Microsoft describes it as viewing user, device, enrollment, configuration and application information without being able to change Intune. Some Microsoft Entra roles, such as Global Reader and Security Reader, also carry read-only Intune access, but Microsoft recommends Intune's own roles over Entra roles for routine work.
  • Someone who can grant consent. Microsoft states that all Intune permission scopes require administrator access, so the first sign-in may need an administrator to approve the requested scopes for the organisation.
  • Ideally a test or lab tenant first. The scripts only read, but a small tenant makes it easy to check the output against the portal.

Two permission layers: scopes and your Intune role

When you sign in with Connect-MgGraph you are using delegated access. The SDK acts on your behalf, and what it can do is the overlap between two things: the scopes (delegated permissions) the app has been granted, and your own rights. Microsoft's permissions guidance puts it plainly - an app can't access anything the signed-in user couldn't. For Intune, those own rights come from Intune role-based access control (RBAC) or an Entra role.

That gives you two independent safety catches. Ask only for Read scopes, and sign in as someone whose Intune role is read-only. If you slip and request a ReadWrite scope, a read-only role still stops the write. If you sign in with a powerful role but request only Read scopes, the token still can't write. Neither layer should be the only one.

This article requests two scopes. DeviceManagementManagedDevices.Read.All covers managed devices and related read-only data such as device categories, detected apps and remote action records. DeviceManagementConfiguration.Read.All covers device configuration profiles and compliance policies, and Microsoft's beta reference lists it for the settings catalog list too. Deliberately not requested: anything ending ReadWrite, DeviceManagementManagedDevices.PrivilegedOperations.All (which allows retire, wipe, remote lock and reboot), and the Apps, Scripts, RBAC and ServiceConfig scopes.

To see what your own account can do inside Intune, open the Intune admin center, go to Tenant administration > Roles, expand Monitor and select My permissions. It lists the combined permissions from all your role assignments.

Install the modules and sign in read-only

Installing the whole Microsoft.Graph module pulls in more than 47 sub-modules. You only need the authentication module and the device management module, so install those two. The v1.0 and beta versions of the SDK are separate modules; this article uses the v1.0 module for the cmdlets and a direct request for the one beta call.

  1. Open PowerShell 7 as a normal user (no elevation needed) and install the two modules for your own profile. PowerShell may ask whether to trust the PowerShell Gallery; answer yes if you are happy to install from it. Allow a minute or two for the download.
    powershell
    Install-Module Microsoft.Graph.Authentication -Scope CurrentUser -Repository PSGallery
    Install-Module Microsoft.Graph.DeviceManagement -Scope CurrentUser -Repository PSGallery
  2. Confirm both modules installed and note their versions.
    powershell
    Get-InstalledModule Microsoft.Graph.Authentication, Microsoft.Graph.DeviceManagement
  3. Sign in interactively, requesting only the two read scopes. The -ContextScope Process option keeps the sign-in to this PowerShell session instead of caching it across sessions, which is a sensible habit on any shared admin workstation. A browser or Windows sign-in window opens. Sign in with your Intune read account and, if prompted, consent to the permissions. If you are not allowed to consent, ask an administrator who can approve for the organisation to run the same command once.
    powershell
    Connect-MgGraph -Scopes 'DeviceManagementManagedDevices.Read.All', 'DeviceManagementConfiguration.Read.All' -ContextScope Process
  4. Check what you actually have. The output should show AuthType as Delegated and your own account, and the scope list should include the two Read scopes you asked for. If it lists anything broader than you requested (left over from earlier work), run Disconnect-MgGraph and connect again.
    powershell
    Get-MgContext | Select-Object Account, AuthType, ContextScope
    Get-MgContext | Select-Object -ExpandProperty Scopes

Export your enrolled devices

Run these steps in the same PowerShell window you signed in with. The export lists devices that Intune manages, using the v1.0 endpoint, and asks Graph for only the properties a device report needs. Leaving out the user's name, email address and the device serial number is deliberate: a fleet report rarely needs personal data, and a file without it is easier to share and safer to lose. The finished files are still business data, so keep them somewhere access-controlled.

  1. Create an output folder in your profile and a timestamp to put in every file name, so two runs never overwrite each other.
    powershell
    $OutDir = Join-Path $HOME 'IntuneReports'
    New-Item -ItemType Directory -Path $OutDir -Force | Out-Null
    $Stamp = Get-Date -Format 'yyyyMMdd-HHmm'
  2. Retrieve the devices. The -All switch follows every page of results; without it you would get only the first page and no warning. On a large estate this can take a few minutes, and it is fine to let it run.
    powershell
    $DeviceProperties = @(
        'id', 'deviceName', 'operatingSystem', 'osVersion', 'complianceState', 'managementState',
        'managedDeviceOwnerType', 'deviceEnrollmentType', 'enrolledDateTime', 'lastSyncDateTime',
        'manufacturer', 'model', 'isEncrypted'
    )
    $Devices = Get-MgDeviceManagementManagedDevice -All -Property $DeviceProperties
    "Devices returned: $($Devices.Count)"
  3. Shape the results into a report and write them to CSV and JSON. The CSV opens in Excel for people; the JSON keeps the same fields for scripts.
    powershell
    $DeviceReport = $Devices | Select-Object Id, DeviceName, OperatingSystem, OsVersion, ComplianceState, ManagementState, ManagedDeviceOwnerType, DeviceEnrollmentType, EnrolledDateTime, LastSyncDateTime, Manufacturer, Model, IsEncrypted
    
    $DeviceReport | Export-Csv -Path (Join-Path $OutDir "managed-devices-$Stamp.csv") -NoTypeInformation -Encoding utf8
    $DeviceReport | ConvertTo-Json -Depth 3 | Set-Content -Path (Join-Path $OutDir "managed-devices-$Stamp.json") -Encoding utf8
  4. Pull two quick answers straight from the data: how many devices sit in each compliance state, and which devices have not checked in for 30 days. The 30-day figure is a starting point for a conversation, not an Intune rule. Devices that have never synced appear in that list too.
    powershell
    $DeviceReport | Group-Object ComplianceState | Select-Object Name, Count
    
    $DeviceReport | Where-Object { $_.LastSyncDateTime -lt (Get-Date).AddDays(-30) } | Sort-Object LastSyncDateTime | Select-Object DeviceName, LastSyncDateTime
  5. Check the result. Open the CSV and confirm the row count matches the device count the script printed. Then compare it with Devices > All devices in the Intune admin center. If your role is limited by scope tags, both the portal and the export show only the devices your role can see, so differences between two admins' totals are expected.
    text
    "Id","DeviceName","OperatingSystem","OsVersion","ComplianceState","ManagementState","ManagedDeviceOwnerType","DeviceEnrollmentType","EnrolledDateTime","LastSyncDateTime","Manufacturer","Model","IsEncrypted"
    "00000000-0000-0000-0000-000000000001","LAB-W11-01","Windows","10.0.26100.1000","compliant","managed","company","windowsAzureADJoin","2026-10-12T09:30:00Z","2026-11-13T07:45:00Z","ExampleCorp","Model A","True"
    "00000000-0000-0000-0000-000000000002","LAB-W11-02","Windows","10.0.26100.1000","noncompliant","managed","company","windowsAzureADJoin","2026-10-14T14:10:00Z","2026-10-02T16:20:00Z","ExampleCorp","Model B","False"

Export policies: v1.0 where possible, beta where required

Intune keeps policies in several places, and a report built from one endpoint is quietly incomplete. Classic device configuration profiles and compliance policies have v1.0 endpoints, and the SDK has v1.0 cmdlets for both. Settings catalog policies live somewhere else. As of 14 November 2026, Microsoft's reference lists the settings catalog list call (deviceManagement/configurationPolicies) under the beta version only; the v1.0 page address returns the beta page. Policies created from endpoint security templates can also appear in that list.

Microsoft supports Intune beta APIs but says they change more frequently, and recommends v1.0 where it exists. So the approach is to use v1.0 for everything that has it and keep the single beta call isolated, with its address in one visible variable. If Microsoft publishes a v1.0 version later, you change one line.

This export lists what exists, not who it applies to. Assignment reporting is a separate query with its own cost in requests. Run these steps in the same session as the device export so the output folder and timestamp are still defined.

  1. Define a small helper for the beta call. It retries when Graph answers 429 (too many requests) or 503 (service unavailable), waiting 5 seconds and doubling the wait each time up to 60 seconds, then gives up after five attempts. Intune endpoints do not reliably send a Retry-After header, so a fixed backoff is the safe fallback. The helper only ever sends GET requests.
    powershell
    function Invoke-GraphGetWithRetry {
        param(
            [Parameter(Mandatory)][string]$Uri,
            [int]$MaxAttempts = 5
        )
        $Delay = 5
        for ($Attempt = 1; $Attempt -le $MaxAttempts; $Attempt++) {
            try {
                return Invoke-MgGraphRequest -Method GET -Uri $Uri
            }
            catch {
                $Status = $null
                if ($_.Exception.Response) { $Status = [int]$_.Exception.Response.StatusCode }
                if (($Status -in 429, 503) -and ($Attempt -lt $MaxAttempts)) {
                    Write-Warning "HTTP $Status from Graph. Waiting $Delay seconds before attempt $($Attempt + 1)."
                    Start-Sleep -Seconds $Delay
                    $Delay = [Math]::Min($Delay * 2, 60)
                }
                else { throw }
            }
        }
    }
  2. Read the v1.0 sets: device configuration profiles and compliance policies. Both use DeviceManagementConfiguration.Read.All. The Type column comes from the @odata.type value and tells you what kind of profile each one is.
    powershell
    $ConfigProfiles = Get-MgDeviceManagementDeviceConfiguration -All | ForEach-Object {
        [pscustomobject]@{
            Source               = 'deviceConfigurations (v1.0)'
            Id                   = $_.Id
            DisplayName          = $_.DisplayName
            Type                 = $_.AdditionalProperties['@odata.type']
            LastModifiedDateTime = $_.LastModifiedDateTime
        }
    }
    
    $CompliancePolicies = Get-MgDeviceManagementDeviceCompliancePolicy -All | ForEach-Object {
        [pscustomobject]@{
            Source               = 'deviceCompliancePolicies (v1.0)'
            Id                   = $_.Id
            DisplayName          = $_.DisplayName
            Type                 = $_.AdditionalProperties['@odata.type']
            LastModifiedDateTime = $_.LastModifiedDateTime
        }
    }
  3. Read the settings catalog policies from the beta endpoint, following the nextLink value until there are no more pages, then reshape each result into the same columns as the others.
    powershell
    $GraphBeta = 'https://graph.microsoft.com/beta'
    $Uri = "$GraphBeta/deviceManagement/configurationPolicies"
    $SettingsCatalogRaw = @()
    while ($Uri) {
        $Page = Invoke-GraphGetWithRetry -Uri $Uri
        $SettingsCatalogRaw += $Page['value']
        $Uri = $Page['@odata.nextLink']
    }
    
    $SettingsCatalog = foreach ($Policy in $SettingsCatalogRaw) {
        [pscustomobject]@{
            Source               = 'configurationPolicies (beta)'
            Id                   = $Policy['id']
            DisplayName          = $Policy['name']
            Type                 = "$($Policy['platforms']) / $($Policy['technologies'])"
            LastModifiedDateTime = $Policy['lastModifiedDateTime']
        }
    }
  4. Combine the three lists, write them to CSV and JSON, and print how many policies came from each source.
    powershell
    $AllPolicies = @($ConfigProfiles) + @($CompliancePolicies) + @($SettingsCatalog)
    
    $AllPolicies | Export-Csv -Path (Join-Path $OutDir "policies-$Stamp.csv") -NoTypeInformation -Encoding utf8
    $AllPolicies | ConvertTo-Json -Depth 3 | Set-Content -Path (Join-Path $OutDir "policies-$Stamp.json") -Encoding utf8
    
    $AllPolicies | Group-Object Source | Select-Object Name, Count
  5. Check the result against the portal. In the Intune admin center, Devices > Configuration should match the configuration profile and settings catalog rows, and Devices > Compliance should match the compliance rows. The sample below shows the JSON shape with illustrative values.
    json
    [
      {
        "Source": "deviceConfigurations (v1.0)",
        "Id": "00000000-0000-0000-0000-00000000a001",
        "DisplayName": "LAB Device restrictions",
        "Type": "#microsoft.graph.windows10GeneralConfiguration",
        "LastModifiedDateTime": "2026-10-20T10:00:00Z"
      },
      {
        "Source": "deviceCompliancePolicies (v1.0)",
        "Id": "00000000-0000-0000-0000-00000000b001",
        "DisplayName": "LAB Windows compliance baseline",
        "Type": "#microsoft.graph.windows10CompliancePolicy",
        "LastModifiedDateTime": "2026-10-21T11:30:00Z"
      },
      {
        "Source": "configurationPolicies (beta)",
        "Id": "00000000-0000-0000-0000-00000000c001",
        "DisplayName": "LAB Edge settings",
        "Type": "windows10 / mdm",
        "LastModifiedDateTime": "2026-11-02T09:15:00Z"
      }
    ]
  6. When you have finished, sign out so the session holds no token.
    powershell
    Disconnect-MgGraph

Paging, throttling and the errors you are most likely to meet

Most problems with a first Intune report fall into a handful of patterns. Knowing them in advance saves a lot of head-scratching.

  • Paging. Graph returns long lists in pages and gives you an @odata.nextLink value to fetch the next one. The -All switch on the SDK cmdlets follows those links for you; the direct request in the settings catalog step follows them in a loop. A result that looks suspiciously short usually means a missed page.
  • Throttling. When you exceed a limit, Graph returns 429 Too Many Requests and Microsoft advises waiting, not retrying immediately, because requests during throttling still count against your usage. For most Intune service areas Microsoft publishes 2,000 requests per 20 seconds per tenant across all apps and 1,000 per app; the Intune devices area has higher figures. Treat these as moving targets and check the throttling limits page for the resource you call. The limits are shared with every other admin and app in the tenant, so you can be throttled while your own volume is modest.
  • Avoid one-request-per-device loops. Listing devices once with -All and -Property is a handful of requests; calling a per-device endpoint for every device is thousands. An independent write-up on Intune rate limiting also notes that Intune endpoints often omit Retry-After, which is why the helper above uses its own backoff.
  • 503 on large listings. Microsoft notes that requesting a large app listing can return 503 Service Unavailable, and recommends retrying with a page size of 20 or fewer. This article does not list apps, but if you extend it that way, add -PageSize 20 to the cmdlet.
  • 403 Forbidden. Either consent has not been granted for the scopes you requested, or your account lacks an Intune role that supports the call. Check the scope list from Get-MgContext, then My permissions in the Intune admin center.
  • Empty results with no error. If scope tags restrict your role, you see only the objects those tags allow. Compare with a colleague holding a different role before assuming data is missing.
  • Scripts endpoints. Since 31 July 2025 the script-related endpoints (device shell scripts, device health scripts and similar) use DeviceManagementScripts scopes rather than DeviceManagementConfiguration. The two scopes in this article will not cover a script inventory, so check the reference page for the exact endpoint before you add one.

Review changes before you automate any

The exports you have just made are the foundation for safer change. A snapshot before and a snapshot after turn the question 'did my change do only what I meant?' into something you can answer by looking. This script compares two policy exports and lists the rows that appear in only one of them. A policy that was edited shows up as a pair: the old row marked with the left arrow indicator and the new row marked with the right.

Replace YOUR_OLDER_EXPORT.csv and YOUR_NEWER_EXPORT.csv with the paths to two files created by the policy export. It only reads local files.

  • Keep reading and writing separate. A reporting script that edits things is just an editing script with a misleading filename. Put write actions in their own file, request ReadWrite scopes only in that file, and sign in again for it.
  • Take a fresh export first and treat it as your before snapshot. Make the change to one pilot object or a small test group, export again and compare.
  • Never point a first run at all users or all devices. Intune's own RBAC guidance advises against giving admins scopes that include all users or all devices for the same reason.
  • Keep secrets out of scripts. Interactive sign-in needs no client secret, certificate or access token, so there is nothing to hard-code or leak. Do not paste tenant IDs into shared scripts, and be careful with Get-MgContext output in tickets because it includes your tenant ID and account.
  • Unattended runs are a separate decision. App-only access needs a certificate or managed identity and application permissions that work without a signed-in user. Microsoft's guidance is that delegated permissions are the recommended approach whenever they meet the need, so reach for app-only only when a scheduled job genuinely requires it.
powershell
$Before = Import-Csv -Path 'YOUR_OLDER_EXPORT.csv'
$After = Import-Csv -Path 'YOUR_NEWER_EXPORT.csv'

Compare-Object -ReferenceObject $Before -DifferenceObject $After -Property Source, Id, DisplayName, LastModifiedDateTime | Sort-Object Id
Technical terms explained
delegated
Access where an app acts on behalf of a signed-in person. It can do only what both the granted scopes and that person's own rights allow.
paging
Returning a long list in chunks. Each chunk includes a link to the next, and a script must follow those links to receive every item.
scope
A named permission, such as DeviceManagementManagedDevices.Read.All, that an app is allowed to use when it calls Microsoft Graph. Scopes are the 'delegated permissions' you consent to when you sign in.
settings catalog
The Intune policy type that lets you pick individual settings from a large, searchable list. Its policies are listed by the configurationPolicies endpoint, which is currently beta only.
throttling
Microsoft Graph deliberately refusing requests for a while when a client sends too many too quickly. It returns HTTP 429 and asks the caller to wait.

Sources and further reading

KEEP THE CONVERSATION GOING

Want a second pair of eyes on your Intune reporting?

If you would like help scoping read-only access, building reports for your Microsoft 365 estate or reviewing a change before it goes near production, get in touch.

Talk to Rismor