This article guides you through the process of integrating Intune data into SDP using a Python script.
Prerequisites: -
Python 3.6 or above
Ensure Python is installed and added to your PATH. Use python --version or python3 --version to verify.
Required Python Libraries:
msal
requests
urllib3
Install them using:
pip install msal requests urllib3
Azure and SDP Credentials:
Client ID, Client Secret, and Tenant ID from Microsoft Graph API.
SDP API Key and SDP URL.
To generate an SDP API Key, navigate to:
ADMIN -> Integration Key -> New
Step 1: Register Application in Intune
1.1 Create a Client ID and Tenant ID:
Log in to Azure Portal.
Navigate to Azure Active Directory > App registrations.
Click New registration and:
Enter your app’s name.
Keep Accounts in this organizational directory only selected.
Click Register.
Copy the Application (client) ID and Directory (tenant) ID from the app’s overview.
1.2 Create a Client Secret:
Go to Certificates & secrets > Client secrets > New client secret.
Provide a description and set Expires to Never.
Click Add and copy the client secret value.
1.3 Add Permissions:
Navigate to API permissions > Add a permission.
Select Microsoft Graph > Application permissions.
Search and select:
DeviceManagementManagedDevices.Read.All.
Click Add permissions and then Grant admin consent for <app name>.
Step 2: Configure the Python Script
In the provided Python script:
Replace placeholders with your details:
"Your_Client_ID" with your Client ID.
"Your_Client_Secret" with your Client Secret.
"Your_Tenant_ID" with your Tenant ID.
"SDP_URL" with your SDP server URL (e.g., https://abc.mdu.zohocorpin.com, without a trailing /).
"API_KEY" with the SDP API Key generated in ADMIN -> Integration Key.
Map additional fields in SDP:
Create Additional Fields for {last connected time, imei, phone number, operation system, os version, wifi mac address, eas identifier and uan} under Admin -> Asset Additional Fields if not created.
In the Python file, search for "def convert_data_to_sdp_asset_json". meta_info will be found below the line. i.e,
make a api call for "/api/v3/assets/_metainfo".
In the response, search of "udf_fields", it should look something like that
From the response, replace the udf field names with the one from the api response. for example, in this case, python file last_connected_time is mapped with "udf_sline_902" but according to the api response, my api key for LAST CONNECTED TIME is udf_sline_301. so I would replace it and my meta data would look like this.
meta_info = {
"last_connected_time": "udf_sline_902",
...
}
Step 3: Execution
After completing the configuration, run the script using one of the following commands:
python SyncIntuneToSDP.py
# or
python3 SyncIntuneToSDP.py
Ensure the script is run from its directory.