简体   繁体   中英

Import Global Address Book from Outlook to Excel or Power BI - Power Query

Has anyone experience how to import global address book from Outlook to Excel/Power BI using Power Query?

I managed to retrieve some of users from my Companies Email using Data from > Exchange Online

let
Source = Exchange.Contents("XYZ.com"),
People = Source{[Name="People"]}[Data]
in
People

But it doesnt give me whole list of Outlook users from the Company...

I found different code but doesnt work for me, it says: my domain doesnt exist. And I am not very familiar with Active Directory and so on...any inputs and tricks?

let
Source = ActiveDirectory.Domains("CompanyDomain.com"),
CompanyDomain.com = Source{[Domain = "CompanyDomain.com"]}[Object Categories],
user = CompanyDomain.com{[Category = "user"]}[Objects],
#"Removed Other Columns" = Table.SelectColumns(user, {"displayName", "user", 
"organizationalPerson"}),
#"Expanded organizationalPerson" = Table.ExpandRecordColumn(#"Removed Other Columns", 
"organizationalPerson", {"department"}, {"department"}),
#"Expanded user 1" = Table.ExpandRecordColumn(#"Expanded organizationalPerson", "user", 
{"mail"}, {"mail"})
in
#"Expanded user 1"

I am using Office365 version.

To import the global address book from Outlook to Excel or Power BI using Power Query, you can use the following steps:

In Excel or Power BI, click on the "Data" tab and select "From Other Sources" > "From Microsoft Exchange." In the "Microsoft Exchange" dialog box, enter your Exchange Online email address and password, and click "OK." In the Navigator window that appears, select the "People" folder and click "Load." This will create a query in the "Queries" pane with the name "People." You can edit this query to remove any unnecessary columns, rename columns, or apply any other transformations as needed. To load the data from the query into an Excel or Power BI table, click the "Close & Load" button. Note that the above steps will only work if you have an Exchange Online account and have been granted access to the global address book by your administrator.

If you are not able to retrieve the global address book using the steps above, it is possible that your administrator has disabled the ability to access the address book from external sources. In this case, you may need to ask your administrator to provide you with the necessary permissions or to export the global address book to a CSV file that you can then import into Excel or Power BI.

Alternatively, you can try using the following code to retrieve the global address book using the Active Directory connector in Power Query:

let
    Source = ActiveDirectory.Domains("CompanyDomain.com"),
    CompanyDomain.com = Source{[Domain = "CompanyDomain.com"]}[Object Categories],
    user = CompanyDomain.com{[Category = "user"]}[Objects],
    #"Removed Other Columns" = Table.SelectColumns(user, {"displayName", "user", "organizationalPerson"}),
    #"Expanded organizationalPerson" = Table.ExpandRecordColumn(#"Removed Other Columns", "organizationalPerson", {"department"}, {"department"}),
    #"Expanded user 1" = Table.ExpandRecordColumn(#"Expanded organizationalPerson", "user", {"mail"}, {"mail"})
in
    #"Expanded user 1"

Note that this code will only work if your organization uses Active Directory and you have the necessary permissions to access the Active Directory domain. You will need to replace "CompanyDomain.com" with your actual domain name.

Create a query that is just the source line above. For example:

let
    Source = ActiveDirectory.Domains("yourdomain.com")
in
    Source

In Power Query, when you click on the Source line on the right, what does it show? In my case, I get a table of domains. It would be one of those values you would use in the "CompanyDomain.com =" line above.

If Source is giving you the error about not finding the domain, then you'll have to have someone tell you what that value is for your company. (Mine was automatically filled in when I chose the Active Directory connector, and it's not just CompanyName.com.)

Hope it helps,

Alan

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM