In Part One of this series, we walked through the foundational steps of identifying our Intune-enrolled devices in Lansweeper and comparing them against an installed software list, by matching assets and writing the necessary IDs to custom fields.
Now, let’s take it further.
In this follow-up, we’ll show how to automatically identify Intune-managed endpoints missing Notepad++ and add them to a dedicated Intune group. This lets you scope a remediation policy (or app deployment) to only those devices where it’s needed – with no manual exports, no CSV wrangling, and no false positives.
Here’s what the automation accomplishes step by step:
deviceId to look up the corresponding Microsoft Graph objectId.You can now scope a Win32 app deployment, configuration profile, or compliance policy directly to this group. In this case, it’s perfect for assigning Notepad++ to the devices that don’t have it.
Not every compliance or software rollout can be tied to static groups, and Intune doesn’t natively scan or inventory software installed on endpoints, so you’d end up scripting a solution with Powershell or similar to do this. By letting Lansweeper serve as the source of truth for installed applications, and using Flow Builder to process the data and integrate with Intune, you can:
It’s a lightweight way to enforce baseline software, and the same logic works for anything you want to report on and throw into an Intune group (think security policies, Attack Surface Reduction groups for Defender rules, and compliance as well).
At the end of the video for part one, I confidently stated the many things that were possible now that we had the AzureID in a custom field, When I then sat down to put my money where my mouth was, I ran into three challenges that made this flow more complex than I expected:
https://graph.microsoft.com/v1.0/directoryObjects/{id}.deviceId. Fortunately we have the ability to create a raw request to:https://graph.microsoft.com/v1.0/devices?$filter=deviceId eq '{deviceId}'&$select=idBefore deploying the Flow:
We are going to need to add the custom field ‘Intune_azureADDeviceId’ that we obtained with Pro Tip 64 to the report. First, duplicate the report, titled “Pro Tip 66 Windows Endpoints Missing Notepad++” and name the report something like ‘Intune Endpoints Missing Notepad++’

Then, edit the report and add the custom field ‘Intune_azureADDeviceId’ (or whatever you named it) to the first ‘Fields’ step:

Next, in the custom code ‘Fields’ step, click on the ‘Custom Fields’ button to get the GUID for the custom field, and copy it:


Then add the field to the custom code, following the syntax of the other fields (quotes, colon, etc.):

Next, in the ‘Group by’ step, add the field to the existing selections:

Then, in the next ‘Fields’ step underneath the ‘Filter’ step, add the field:

Finally, at the last filter step, click ‘+’ and add the ‘And’ Intune_azureADDeviceId > Exists:

Download (from above) the .zip file that contains the .yml file that you will import.
In Flow Builder, click the ‘+’ to add a workflow:

Choose ‘Import’:

Choose ‘Select a file’ > and either drag the .yml file over, or choose ‘Choose file’ and upload it:

Since this uses custom fields and custom code, I simply exported the file for us to use, versus making it a template. As a result, we need to adjust things inside the flow before it will work.
First, Click the ‘Configuration Wizard’:

The lansweeper connection is unique to your site – so we will need to delete the existing connection:

Now, we simply choose ‘+ Connection’:

And add the Lansweeper connection back:


Next, since I removed my own Intune Connection information (i.e. my own ClientID and Secret), we will need to ‘edit’ the existing Intune connection:

Now, Enter in the ClientID and Client Secret that you set up in Azure (see the pre-requisite section for info):

Next, since we deleted and recreated the Lansweeper Connection, we will need to edit and re-link the lansweeper connector that pulls the report to the newly created connection:

In the ‘Connection’ input field, click the ‘LS connection’ connection choice to re-link it:

Now, we need to fix the testing configuration, as you can see from the red warning. Click ‘Test Configuration’:

Now, double-click* (took me a minute to figure that out) the ‘Test Instance Configuration’ section:

Press ‘Connect’ to connect to Intune/M365:

A new browser tab will open, and you will be prompted to connect to M365. After you sign in, you will either see a success or a fail on the authorization. If you get a failure page, double-check your clientID and client secret:

Once connected, click ‘Finish’:

Now, the red errors from the flow we imported should all be gone:

Now we need to put the reportID back in the Lansweeper connector that pulls the report info. To get the ID, pull up the report and copy it from the URL (it will be different than the ID I used):

Click the connector, and paste the Report ID in the field:

Now, take the ‘Object ID’ from the Intune group that you created:

And paste it into the Intune Connector that gets the group members:

Likewise, paste it into the Intune connector that adds endpoints to the group:

Now, everything should be good to go! Press ‘Run’ to test everything out:

You should see all green, and the flow will have successfully added the endpoints to the group! – if you get any errors, you can click the step and see the error.

Note* If you add any columns to the report, the field number for Intune_azureADDeviceId might have moved around. It is being referenced in the ‘Clean CSV Data’ code block, and also the ‘Loop Over Missing Notepad Endpoints’ section. If you get errors on the Loop step, check the test output for the ‘Parse’ step, expand index 0, and make note of the field number that ‘Intune_azureADDeviceId’ and modify the other steps with that number.

Congratulations! You now have a ‘dynamic’ static group, that you can attach the notepad++ win32 application remediation to!
Here’s a breakdown of how this works:
Step 1: Flow Trigger (webhook) – I just put a webhook in here but you can make it whatever you want by editing it (example: a schedule).
This step queries the Lansweeper API for a report listing all Windows devices that are missing Notepad++. It serves as the authoritative data source for the flow.
6835373544e3bacbf53b63b8)The output of the above is all in one payload – in order for it to be used in further steps, it must be parsed out into indexes.

Lansweeper returns report data as raw CSV. This step turns it into a structured format (array of arrays) for filtering and looping.
getLansweeperReportMissingNotepad.results.',').
This code step removes the header row, empty rows, and any row missing a valid Entra (Intune) Device ID. This ensures only valid rows are processed downstream.
stepResults.parse.results.data.
Now we process each valid row individually. This allows us to validate whether the device is still enrolled in Intune.
cleanCsvData.results.cleanedData.
We now use the Intune Device ID to check if the device is still valid and retrievable from Microsoft Graph. If found, we extract its object ID for later group management.
v1.0GET/devices$filter:deviceId eq '{{$loopOverMissingNotepadEndpoints.currentItem.9}}'$select:id — this ensures only the device’s object ID is returned.Microsoft Intune Connection.
We now create a branch that checks if the device lookup succeeded. If it did, we save the object ID; if not, we log the failure.
isNotEmpty(lookupDeviceViaGraphApi.results.value).
This captures the id field of the found device and stores it in a list for later processing.
foundIntuneIdsList — this is a temporary list that will hold all valid object IDs.lookupDeviceViaGraphApi.results.value.0.id — this points to the object ID of the device just found.
We log the lookup failure for auditing or troubleshooting purposes.
Device not found for Intune_ID: {{$loopOverMissingNotepadEndpoints.currentItem.8}}, Graph Response: {{JSON.stringify(getRequest.results)}}Now that the loop is finished, we retrieve the list of verified Intune object IDs.
foundIntuneIdsList.[].
This adds extra safety to confirm the list is valid for processing — especially important for custom scripting.
memberIdsArray.null, a string, or an empty value.We must convert each device object ID into a full directoryObjects/{id} Graph URL — this is the format required when adding group members. *This was the tricky part that took a lot of back-and-forth with GPT and Gemini to help me get the code right.
memberIdsArray and return:https://graph.microsoft.com/v1.0/directoryObjects/<id>memberUrls.
We fetch the list of devices already in the target Intune group. This helps us avoid adding duplicates.
b5399f33-209a-4c36-b4cd-436dcbeb83d1.
This step builds a case-insensitive lookup map from the current group members for fast comparison. The code also marks the objects with ‘true’ for us to filter out existing members in step 13 below.
getCurrentGroupMembers.results.value.
We now remove any devices that are already in the group from our list of candidates.
memberUrlsnewMemberUrls.If there are any new devices remaining, we proceed to add them. If not, we log and exit gracefully.
isNotEmpty(filterNewMembers.results.newMemberUrls)We now submit the filtered device list to Microsoft Graph to update the group.
b5399f33-209a-4c36-b4cd-436dcbeb83d1filterNewMembers.results.newMemberUrlsAdded New Member: {{$filterNewMembers.results.newMemberUrls}}No new members found to add to the groupExplore the full platform, free for 14 days.
No credit card required.