1
+ # ###########################################################################################
2
+ # #
3
+ # # This script uploads custom macOS configuration profiles to Microsoft Intune using the Microsoft Graph API.
4
+ # #
5
+ # ###########################################################################################
6
+
7
+ # # Copyright (c) 2025 Microsoft Corp. All rights reserved.
8
+ # # Scripts are not supported under any Microsoft standard support program or service. The scripts are provided AS IS without warranty of any kind.
9
+ # # Microsoft disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a
10
+ # # particular purpose. The entire risk arising out of the use or performance of the scripts and documentation remains with you. In no event shall
11
+ # # Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever
12
+ # # (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary
13
+ # # loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility
14
+ # # of such damages.
15
+
16
+ #
17
+
18
+ # ################################################
19
+ # Configuration Variables
20
+ # ################################################
21
+
22
+ # Modify the $policyPrefix variable to change the prefix for the configuration names.
23
+ # This prefix will be prepended to each configuration profile name in Intune
24
+ $policyPrefix = " MDE (imported) - "
25
+
26
+ # Array of Microsoft Defender for Endpoint (MDE) mobile configuration files to upload
27
+ # These files contain various security and permission settings for macOS devices
28
+ $files = @ (
29
+ " accessibility.mobileconfig" , # Accessibility permissions for MDE
30
+ " background_services.mobileconfig" , # Background service permissions
31
+ " bluetooth.mobileconfig" , # Bluetooth access permissions
32
+ " fulldisk.mobileconfig" , # Full disk access permissions
33
+ " kext.mobileconfig" , # Kernel extension permissions
34
+ " netfilter.mobileconfig" , # Network filter permissions
35
+ " notif.mobileconfig" , # Notification permissions
36
+ " sysext.mobileconfig" , # System extension permissions
37
+ " sysext_restricted.mobileconfig" # Restricted system extension permissions
38
+ )
39
+
40
+ # ################################################
41
+ # Prerequisites and Authentication
42
+ # ################################################
43
+
44
+ # Ensure you have the Microsoft Graph PowerShell SDK installed
45
+ # Run this command if you haven't installed it yet:
46
+ # Install-Module Microsoft.Graph -Scope CurrentUser
47
+
48
+ # Connect to Microsoft Graph with the required permissions for device configuration management
49
+ # This will prompt for authentication if not already signed in
50
+ Connect-MgGraph - NoWelcome - Scopes " DeviceManagementConfiguration.ReadWrite.All"
51
+
52
+ # ################################################
53
+ # Main Processing Loop
54
+ # ################################################
55
+
56
+ # Process each mobile configuration file
57
+ foreach ($file in $files ) {
58
+ $FileContent = (Invoke-WebRequest - Uri " https://raw.githubusercontent.com/microsoft/mdatp-xplat/refs/heads/master/macos/mobileconfig/profiles/$file " - Method GET).Content
59
+ $payload = [System.Convert ]::ToBase64String([System.Text.Encoding ]::UTF8.GetBytes($FileContent ))
60
+ $FileName = $file -replace " .mobileconfig" , " "
61
+ $json = ' {
62
+ "id": "00000000-0000-0000-0000-000000000000",
63
+ "displayName": "' + $policyPrefix + $FileName + ' Configuration",
64
+ "roleScopeTagIds": [
65
+ "0"
66
+ ],
67
+ "@odata.type": "#microsoft.graph.macOSCustomConfiguration",
68
+ "deploymentChannel": "deviceChannel",
69
+ "payloadName": "' + $FileName + ' ",
70
+ "payloadFileName": "' + $file + ' ",
71
+ "payload": "' + $payload + ' "
72
+ }'
73
+ Write-Host $FileName - ForegroundColor Green
74
+
75
+ $uri = " https://graph.microsoft.com/beta/deviceManagement/deviceConfigurations"
76
+ $graphAction = " POST"
77
+ Invoke-MgGraphRequest - Uri $uri - Method $graphAction - Body $json - ContentType " application/json"
78
+ Write-Host " Uploaded $FileName configuration" - ForegroundColor Cyan
79
+ }
0 commit comments