Hi,
There are two ways you can do this.
A. Using device logic :
1) Dump all users into a CSV> Get-AzureADUser -ALL
2) Dump all devices along with properties into a CSV and use the device owner attribute to check against the all users list
This is complicated and might not be the easiest way.
B. Use Licenses :
Azure AD has license SKU's which have all the service plans like Intune, exchange online, Azure AD premium etc defined. So you can directly fetch users who have a specific SKU assigned and check which service plan they have enabled against them.
List of all services: https://learn.microsoft.com/en-us/azure/active-directory/users-groups-roles/licensing-service-plan-reference
You can use powershell to do this directly
Ref: https://learn.microsoft.com/en-us/office365/enterprise/powershell/view-account-license-and-service-details-with-office-365-powershell
You can also use Azure AD dynamic groups which have a property called assigned plans to filter the users. This will automatically create a group of all the people with/ without Intune license as per the logic you provide.
Hope this helps.