### FILE: index.php graphCall($endpoint, $accessToken, 'GET'); return $response; } catch (Exception $e) { echo 'Error fetching compliance policies: ' . $e->getMessage(); return null; } } // Retrieve the list $compliancePolicies = fetchDeviceCompliancePolicies($ms, $_SESSION['ms_access_token']); // Render premium card with fetched data echo render_premium_card('Device Compliance Policies', json_encode($compliancePolicies)); ?> ### FILE: scripts/Automation.ps1 <# .SYNOPSIS Retrieves and exports all devices under Intune management. .DESCRIPTION This script connects to Microsoft Graph using the MgGraph module, retrieves all managed devices, and exports the list to a CSV file. .EXAMPLE .\Automation.ps1 .NOTES Author: Souhaiel Morhag Company: MSEndpoint.com Blog: https://msendpoint.com Academy: https://app.msendpoint.com/academy LinkedIn: https://linkedin.com/in/souhaiel-morhag GitHub: https://github.com/Msendpoint License: MIT #> try { # Connect to Microsoft Graph Connect-MgGraph -Scopes "DeviceManagementConfiguration.Read.All" # Retrieve the list of managed devices $devices = Get-MgDeviceManagementManagedDevice # Export the devices to a CSV file $devices | Export-Csv -Path "intune_devices.csv" -NoTypeInformation Write-Output "Device list exported successfully to intune_devices.csv." } catch { Write-Error "Failed to export device list: $_.Exception.Message" }