MS Intune Integration using Script - v1

MS Intune Integration using Script - v1

This article guides you through the process of integrating Intune data into SDP using a Python script.

 

Prerequisites:  -

  1. Python 3.6 or above
    Ensure Python is installed and added to your PATH. Use python --version or python3 --version to verify.

  2. Required Python Libraries:

    • msal

    • requests

    • urllib3

  1. Install them using:

 pip install msal requests urllib3 

            If the above command doesn't work, try installing them individually i.e, pip install msal 
  1. 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:  

  1. Log in to Azure Portal.

  2. Navigate to Azure Active Directory > App registrations.

  3. Click New registration and:

    • Enter your app’s name.

    • Keep Accounts in this organizational directory only selected.

    • Click Register.

  1. Copy the Application (client) ID and Directory (tenant) ID from the app’s overview.

1.2 Create a Client Secret:  

  1. Go to Certificates & secrets > Client secrets > New client secret.

  2. Provide a description and set Expires to Never.

  3. Click Add and copy the client secret value.

1.3 Add Permissions:  

  1. Navigate to API permissions > Add a permission.

  2. Select Microsoft Graph > Application permissions.

  3. Search and select:

    • DeviceManagementManagedDevices.Read.All.

  1. Click Add permissions and then Grant admin consent for <app name>.

 

 

 

Step 2: Configure the Python Script  

In the provided Python script:

  1. 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.

  1. 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.


How to Schedule in Custom Script :-

1. Admin -> Custom Schedules
2. Choose Execute Script as the Executor
3. Specify the fileName (i.e, SyncIntuneToSDP.py). make sure to place the file in the directory as mentioned in the Custom Schedule Page.
4. Choose the desired date and frequency

                  New to ADSelfService Plus?

                    • Related Articles

                    • Integration with other helpdesk tools

                      Please note that, we do not have direct integration of SDP MSP with other HelpDesk tools like ServiceNow. However if any HelpDesk has APIs for all Create, Update, Close operations, then you can make use of the our APIs and custom triggers to achieve ...
                    • How to update Request Additional fields during request create/update using Business Rules

                      This is a sample python script to update the Request Additional Field Values during request create/update based on certain criteria using Business Rules Execution Steps:  1. Download the attached zip 2. Move the files to ...
                    • Script to add worklog using custom schedule

                      What is a Custom Schedule? Custom Schedules are actions scheduled on a specific date and time with or without repeat frequency. The actions are specified in a customized script file. Any data from ServiceDesk Plus can be sent to the script through ...
                    • Azure DevOps Integration

                      Feature: Azure DevOps Integration <--> ServiceDeskPlus (Plugin Model) --> Create a new work-item in Azure DevOps when a request is created in SDP --> Update SDP request status when a Azure DevOps work-item status is updated --> Updating Comments and ...
                    • Slack Integration

                      This is a sample python script that is used to post request details from ServiceDesk Plus into Slack.Slack is a cloud-based team collaboration tool that allows team members to communicate without the use of emails or group SMS. Use Case: Lets assume ...