Collectors/IntuneConfiguration.ps1

@{
    Name           = 'IntuneConfiguration'
    FileName       = 'intuneConfiguration'
    ApiVersion     = 'v1.0+beta'
    RequiredScopes = @('DeviceManagementConfiguration.Read.All')
    Description    = 'Intune device configuration profiles (v1.0) and Settings Catalog policies (beta, incl. raw settings) with assignments.'
    Collect        = {
        $deviceConfigurations = @(Invoke-TLGraphRequest -Uri '/v1.0/deviceManagement/deviceConfigurations?$expand=assignments' -All)

        # Settings Catalog only exists on the beta endpoint - parse defensively.
        $settingsCatalogPolicies = @()
        $settingsCatalogAvailable = $false
        try {
            $settingsCatalogPolicies = @(Invoke-TLGraphRequest -Uri '/beta/deviceManagement/configurationPolicies?$expand=assignments,settings' -All)
            $settingsCatalogAvailable = $true
        }
        catch {
            Write-Verbose ("Settings Catalog policies with settings failed, retrying without settings: {0}" -f $_.Exception.Message)
            try {
                $settingsCatalogPolicies = @(Invoke-TLGraphRequest -Uri '/beta/deviceManagement/configurationPolicies?$expand=assignments' -All)
                $settingsCatalogAvailable = $true
            }
            catch {
                Write-Verbose ("Settings Catalog (beta) not available: {0}" -f $_.Exception.Message)
            }
        }

        @{
            deviceConfigurations     = $deviceConfigurations
            settingsCatalogPolicies  = $settingsCatalogPolicies
            settingsCatalogAvailable = $settingsCatalogAvailable
        }
    }
}