mtcoffee / mtcoffee.github.io

A github pages blog
MIT License
0 stars 1 forks source link

servicenow-microsoft-intune-import/ #4

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

ServiceNow Microsoft Intune Import - An IT and Dev Blog

This post will cover a method used to import Microsoft Intune data in the CMDB. In this example, we will use the Microsoft Graph API. The official discovery plugin is mapped here, which we will reference.

https://meatsac.github.io/servicenow-microsoft-intune-import/

TheNomadBR commented 2 years ago

Nice work! The only thing that didn't work well for me was the Open In Intune button, but I presume is because I don't have permissions there.

tamparongrichards commented 2 years ago

Hello. Im currently doing and Im still in the first part and Im already getting an error.

I have been having this error: { "error": { "code": "InvalidAuthenticationToken", "message": "CompactToken parsing failed with error code: 80049217", "innerError": { "date": "2022-06-29T04:51:39", "request-id": "ad638c36-d272-46e9-aaa8-aeef99efa29a", "client-request-id": "ad638c36-d272-46e9-aaa8-aeef99efa29a" } } }

would it be possible if you can create a more detailed instruction starting from setting the details in the microsoft end (Azure)

mtcoffee commented 2 years ago

Microsoft mentions the error "CompactToken parsing failed with error code: 80049217" at the link below.
https://docs.microsoft.com/en-us/azure/app-service/scenario-secure-app-access-microsoft-graph-as-user?tabs=azure-resource-explorer#configure-app-service-to-return-a-usable-access-token

The official docs from Microsoft go further in to detail. You can find them here. https://docs.microsoft.com/en-us/mem/intune/developer/intune-graph-apis

tamparongrichards commented 2 years ago

Hello meatsac、Thank you very much for the fast responds and Im sorry for the late response since I temporarily stopped working on this due to other tasks came up. Currently I am doing "Create a data source and load data into staging tables" and it seems like the instruction is already out dated. according to step 6, "If successful, you should receive a message like this and staging data is now loaded in “IntuneDevices” temp table." but there was no table created despite that it was successful. Should I just create a staging table manually or there is a way to automate it?

mtcoffee commented 2 years ago

If the load was succesful it would have had to create a staging table. You may need to reload your browser but it should be listed under "Import Set Tables". Alternatively you can get a list of import set tables by querying the table "sys_db_object" with filter extends table is "import set row".

tamparongrichards commented 2 years ago

Hey meatsac! Thanks for the reply. I solved it already. The fault was the value is not "company" on the script but "personal". I have another question. The 3 field below to be created for the cmdb_ci_computer is custom field. If my understanding is right, this table is oob table in the global instance. If Im not mistaken, it is not advisable to edit oob tables. Is there other solution to this?

intune_compliance (custom field)
intune_deviceregistrationstate (custom field) intune_deviceenrollmenttype (custom field)

mtcoffee commented 2 years ago

Adding custom fields to CMDB tables is a common practice but try to reuse existing fields when it makes sense to do so. This is a good question to bring up on the ServiceNow community. https://community.servicenow.com/community?id=community_forum&sys_id=75291a2ddbd897c068c1fb651f9619f3

naxis commented 1 year ago

Hey Meatsac, I do not understand something with the transform map. userprincipalname (choice action = ignore) > assigned_to > No

The target table assigned_to reference the sys_user but from intune I have the email address in userprincipalname. I guess that I have to write a script to grub the corresponding user record.

Regards

mtcoffee commented 1 year ago

Hi naxis,

That may be necessary. The demo I set this up for was using a full UPN for the user_name field so it worked as is. The community has a solution for you here: https://www.servicenow.com/community/developer-forum/transform-map-script-changing-email-address-to-user-name/m-p/1379171