0

I'm looking for a way to export organisation hierarchy that is stored in our Office365 environment. There is a feature in Outlook / MS teams where you can look at the organisation, but it is very limited and only shows those who report to the same manager, and the levels above and below the person. I.e., its not possible to get a view of the organisation as a whole, only parts of it.

Every employee in our AAD has their manager field and the department field filled. I can export lists of employees and the departments they belong to, but the field "manager" is never filled. I've tried several admin portals to export all users and get the "manager" colums aswell, but that field is not exported when I tried from the AAD-, Exchange-, outlook and the general office365 admin portal*.

I just want to get a neat CSV out with the name of the employee, their department, their closest manager so that I can create a visual org.chart of the organisation as a whole through mermaid or any other scripting language.

*The links that I used for the various portals are:

KhaaL
  • 1
  • 1
  • 1
  • Thank you for reaching out to us We will investigate and if we require further information we will reach out. Best regards, Teams Platform – Gousia Begum Jul 07 '20 at 07:26
  • Have you looked at the [Microsoft Graph](https://learn.microsoft.com/en-us/graph/api/intune-shared-user-list) for this? – Kalyan Krishna Jul 07 '20 at 09:20
  • Could you please try using the [Get organisation](https://learn.microsoft.com/en-us/graph/api/resources/organization?view=graph-rest-1.0) Graph API and see if that helps? – Gousia Begum Jul 07 '20 at 09:27
  • Thanks for the tips about Graph API,@Gousia-MSFT and @KalyanKrishna ! I did try with https://graph.microsoft.com/v1.0/users but it does not output the manager field either, but the other information (title, name, phone etc) does display correctly... – KhaaL Jul 08 '20 at 12:03

2 Answers2

1

You can get the detailed information of the organization by calling the graph api. If you need to read all the properties, you need to add the Organization.Read.All permission. Don’t forget to grant the administrator consent for this permission.

Get https://graph.microsoft.com/v1.0/organization

enter image description here

Related Information: https://learn.microsoft.com/en-us/graph/api/organization-get?view=graph-rest-1.0&tabs=http and https://learn.microsoft.com/en-us/graph/api/resources/directoryobject?view=graph-rest-1.0

Carl Zhao
  • 8,543
  • 2
  • 11
  • 19
  • Thank you for the answer! I might have been a bit obscure in describing what I want to get out, namely the org.chart of relationships between employees and their managers. Using "Get https://graph.microsoft.com/v1.0/organization" gets me info about the organisation, but what I wanted is the information in https://graph.microsoft.com/v1.0/users - but with the managerial relationship which unfortunatly did not come out when I run the query. – KhaaL Jul 08 '20 at 12:00
0

This is possible with MS Graph either through API or through PowerShell.

Rough idea is to gather all the user ids and loop through all ID's and their respective manager or direct reports.

For the Powershell there is also a roughly direct solution for you: https://github.com/ruudmens/LazyAdmin/blob/master/MsGraph/Get-MgUsers.ps1

More easy-to-process information about the solution: https://lazyadmin.nl/powershell/get-mguser/

Documentation: https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.users/get-mguser?view=graph-powershell-1.0

If you prefer the API:

https://learn.microsoft.com/en-us/graph/api/user-list-directreports?view=graph-rest-1.0&tabs=http

https://learn.microsoft.com/en-us/graph/api/user-list-manager?view=graph-rest-1.0&tabs=http

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](https://stackoverflow.com/review/late-answers/32307257) – Nol4635 Jul 28 '22 at 00:28