Jump to content

Recommended Posts

Posted

Hi All,
I just wanted to check what a supported or best method is for regular asset imports from Microsoft (Azure) Intune?

I noticed that the newer/newest asset_import.exe comes with a sample conf_example_intune.json -  https://docs.hornbill.com/data-imports-guide/assets/configexamples/intune .
Unfortunately I can't get that to work for us with error "..No ... asset records returned from Intune - check your configuration!"

I then noticed some articles implying that the above won't work and you'd best use this powershell script
HornbillAzureIntuneAssetImport.ps1 


Ideally I'd like to use the asset_import utility as we've already utilised this for many other type of asset imports and I'd like to avoid using different mechanisms needlessly.
Regards,
Jörg

  • 2 weeks later...
Posted

So, I still don't know which is the better or preferred method.
However I've fiddled about with the asset_import.exe method starting with the included conf_example_intune.json.
I'm still disappointed with the lack of documentation around this method as there are numerous aspects in the conf I've no idea how they work, what they do, if they're required and how I can change them.
So for now I'm left with a disappointing trial and error approach.

During this testing I changed '"AssetType": "Smart Phone"' to something else which didn't work and then changed it back - and even though the setting I changed it back to hadn't worked before works now!
So the following is what works for me atm. Most attributes populate, although some don't (e.g. osVersion). I've not yet troubleshooted those.

asset_import.exe -dryrun=false -debug=true -file=conf_intune_dynamic_Mobiles_test01.json

conf_intune_dynamic_Mobiles_test01.json:
{
    "KeysafeKeyID": <redacted>,
    "LogSizeBytes": 10000000,
    "HornbillUserIDColumn": "h_user_id",
    "SourceConfig": {
        "Source": "intune",
        "Intune": {
            "Fields": [
                "id",
                "userId",
                "deviceName",
                "operatingSystem",
                "osVersion",
                "userPrincipalName",
                "model",
                "manufacturer",
                "serialNumber",
                "userDisplayName",
                "managedDeviceName",
                "phoneNumber",
                "subscriberCarrier",
                "imei"
            ]
        }
    },
    "AssetTypes": [
        {
            "AssetType": "Smart Phone",
            "OperationType": "Both",
            "PreserveShared": false,
            "Query": "model eq 'iPhone 12 mini' or model eq 'iPhone 13 mini' or model eq 'iPhone 14' or model eq 'iPhone 15' or model eq 'SM-A326B' or model eq 'SM-A346B' or model eq 'SM-A546B'",
            "AssetIdentifier": {
                "SourceColumn": "deviceName",
                "Entity": "AssetsMobileDevice",
                "EntityColumn": "h_name"
            }
        }
    ],
    "AssetGenericFieldMapping": {
        "h_name": "{{.deviceName}}",
        "h_asset_tag": "{{.deviceName}}",
        "h_description": "Imported from Intune.",
        "h_supported_by": "{{.subscriberCarrier}}",
        "h_used_by_name": "{{.userPrincipalName}}",
        "h_used_by": "{{.userPrincipalName}}"
    },
    "AssetTypeFieldMapping": {
        "h_name": "{{.deviceName}}",
        "h_imei_number": "{{.imei}}",
        "h_model": "{{.model}}",
        "h_manufacturer": "{{.manufacturer}}",
        "h_os_description": "{{.operatingSystem}}",
        "h_os_version": "{{.osVersion}}",
        "h_phone_number": "{{.phoneNumber}}",
        "h_serial_number": "{{.serialNumber}}"
    }
}

  • Like 2
Posted

What I'm yet to figure out is - and would be grateful for any suggestions on:

- what are the attributes Intune provides and what are their proper names
- which of those attributes can I get
- which of those attributes can I use for queries in asset_import  (some I know I can get but cannot query on)
- what are the query comparison operators available for this Intune asset_import. 
   We know that the below works.
   "Query": "model eq 'iPhone 12 mini' or model eq 'iPhone 13 mini' or model eq 'iPhone 14' or model eq 'iPhone 15' or model eq 'SM-A326B' or model eq 'SM-A346B' or model eq 'SM-A546B'",
   However that's very static and I cannot get something more flexible and dynamic to work which works for other imports, e.g.:
   "Query": "model CONTAINS 'iPhone' or model CONTAINS 'SM-'",

Posted

Useful thanks, I am looking at Laptop/Desktops/Tablets in the first instance, but this looks like a good start point

  • Like 1
Posted

I was recently and rightly pointed to documentation by Hornbill and Microsoft which, at least in theory, answers many of my questions from above.
I had seen some of them before but read them too hastily. There's a lot of detail, I needed to take my time.

https://docs.hornbill.com/data-imports-guide/assets/configuration
explains a lot of the structure of the conf.json files, what attributes are for and how they're applied, etc.
It also explains what query operators you can use for intune imports. Though I still keep not finding this entry even though I now know it's there. 
It's: "Microsoft Graph oData filter for returning asset details from Intune. See the filter parameter documentation https://learn.microsoft.com/en-us/graph/filter-query-parameter?tabs=http from Microsoft for instruction of how these filters can be constructed, and the managed device resource type documentation https://learn.microsoft.com/en-us/graph/api/resources/intune-devices-manageddevice?view=graph-rest-1.0#properties for a list of available properties."

The issue now is that I can't make these filter parameters work. E.g.:

  • This works ok:   
    "Query": "model eq 'iPhone 12 mini' or model eq 'iPhone 14' or model eq 'SM-A326B' or ..." 
  • However none of these options listed/implied in the documentation work:
    "Query": "model startsWith 'iPhone'",
    "Query": "startsWith(model, 'iPhone')",
    "Query": "model in ('iPhone 12 mini', 'iPhone 13 mini', 'iPhone 14')",
    "Query": "model contains 'iPhone'",
    For all of those I keep getting this error message:  "No Smartphone asset records returned from Intune - check your configuration!"
  • I tried adding a "AdditionalFilters" section (as shown in the example conf.json in docs.hornbill.com/data-imports-guide/assets/configuration), but that stopped it working, too


Any idea how I can structure the query more generically?

Posted
On 18/04/2024 at 18:26, Jörg Walther said:

I was recently and rightly pointed to documentation by Hornbill and Microsoft which, at least in theory, answers many of my questions from above.
I had seen some of them before but read them too hastily. There's a lot of detail, I needed to take my time.

https://docs.hornbill.com/data-imports-guide/assets/configuration
explains a lot of the structure of the conf.json files, what attributes are for and how they're applied, etc.
It also explains what query operators you can use for intune imports. Though I still keep not finding this entry even though I now know it's there. 
It's: "Microsoft Graph oData filter for returning asset details from Intune. See the filter parameter documentation https://learn.microsoft.com/en-us/graph/filter-query-parameter?tabs=http from Microsoft for instruction of how these filters can be constructed, and the managed device resource type documentation https://learn.microsoft.com/en-us/graph/api/resources/intune-devices-manageddevice?view=graph-rest-1.0#properties for a list of available properties."

The issue now is that I can't make these filter parameters work. E.g.:

  • This works ok:   
    "Query": "model eq 'iPhone 12 mini' or model eq 'iPhone 14' or model eq 'SM-A326B' or ..." 
  • However none of these options listed/implied in the documentation work:
    "Query": "model startsWith 'iPhone'",
    "Query": "startsWith(model, 'iPhone')",
    "Query": "model in ('iPhone 12 mini', 'iPhone 13 mini', 'iPhone 14')",
    "Query": "model contains 'iPhone'",
    For all of those I keep getting this error message:  "No Smartphone asset records returned from Intune - check your configuration!"
  • I tried adding a "AdditionalFilters" section (as shown in the example conf.json in docs.hornbill.com/data-imports-guide/assets/configuration), but that stopped it working, too


Any idea how I can structure the query more generically?

You can use the REGEX functions....
like ...

 

    "AssetFilters": [{
        "ColumnName":"h_description",
        "ColumnValue": ".*from Intune",
        "Operator": "Regex",
        "IsGeneralProperty": true

gives all descriptions ending with from Intune  (that is from a delete script).
But basically I found you can use Regex for conditions start end etc.

I tested mine here regex101: build, test, and debug regex

On 15/02/2024 at 10:30, philip ross said:

i solved it.... 

 

        "h_type" : "2"

 

  • Like 1
Posted

Hi Philip,
Thanks very much for the suggestion.
I had tried a regex before in various forms, but failed every time. I'd used the "AdditionalFilters" section as suggested in the Hornbill documentation, rather than your "AssetFilters".
Because of your suggestion I've tried again, still using "AdditionalFilters", but because I couldn't quite figure out how to structure the regex in the context of the conf.json I actually asked Copilot for a 'golang' format (saw this for hornbill) - which suggested:

regexp.MustCompile(`^(iPhone|SM-)`)

So I transposed this into conf.json and it actually worked!
This is the relevant portion of my conf.json:

 

    "AssetTypes": [
        {
            "AssetType": "Smartphone",
            "OperationType": "Both",
            "PreserveShared": false,
            "Query": "",
            "AdditionalFilters": [
                    {
                      "Field": "model",
                      "Operator": "REGEXMATCH",
                      "Value": "^(iPhone|SM-)"
                    }
                  ],
            "AssetIdentifier": {
                "SourceColumn": "deviceName",
                "Entity": "AssetsMobileDevice",
                "EntityColumn": "h_name"
            }
        }
    ],




So this is trying to get any record where their 'model' startswith "iPhone" or "SM-".

I've now got what I was looking for with our Intune imports
- obvs successfully connect to Intune, identify and export all fields with their correct attributes
- filter generically, so that new records of newer models are captured automatically (as much as possible); e.g.  "Operator": "REGEXMATCH", "Value": "^(iPhone|SM-)"
- work with strings within the conf.json, so I can only import relevant string portions; e.g.:    "h_used_by": "{{ (split \"@\" .userPrincipalName)._0 }}",     (this only gets the first portion of the UPN)


I attached our complete conf.json if anyone's interested.

conf_Intune_dynamic_Mobiles.json

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...