Forum Discussion

lucadelicio's avatar
lucadelicio
Icon for Impactful Individual rankImpactful Individual
2 years ago
Solved

Import Sharepoint Groups: UserId - GroupId

Goodmorning everybody,

i need your precious help.

I need to import the Sharepoint Groups from Sharepoint.

The result that i need is a table with:
UserId - GroupId - UserName - GroupName.
For now i'm able to import the sharepoint list and from the "Item" i have imported the users and the groups but i can't linked it.
In other words i need to import the result of the "(sharepointsites)/_layouts/15/user.aspx" which shows all groups and all users for each group.
I searched a lot but didn't find any answers.
Can anyone could help me please?
Thank you very much in advance!

 

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi lucadelicio ,

     

    Hope all is going well.

     

    In order to solve your problem, here is the method I provide:

     

    Use a PowerShell script to export user and group information to a CSV file, and then import the CSV file into Power BI. You need to connect to SharePoint Online before doing this. The following documents provide specific steps for your reference:

    Manage SharePoint users and groups with PowerShell - Microsoft 365 Enterprise | Microsoft Learn


    If you have any questions please feel free to contact me, I hope my answers can help you.

     

    Best Regards,
    Yang
    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    • lucadelicio's avatar
      lucadelicio
      Icon for Impactful Individual rankImpactful Individual

      Goodmorning,

      i'm trying to use the SP.GroupCollection.getById().

      I create in Power Query a function with a parameter.

      If i arrange the result is ok, but the problem is that i have to invoke the method from the function manually n times for all my group.

       

      There is a method to call every group in one get or to invoke the get for a list (the item list of my groups)?

      Thank you

  • lucadelicio's avatar
    lucadelicio
    Icon for Impactful Individual rankImpactful Individual

    Hi everybody,

     

    and thanks for the answer.

     

    I want to share with you the solution that i find on a post.

     - I create a function with a parameter that use the GET
    let
    Source = (Offset) =>
    let
    Source =
    Xml.Tables(Web.Contents("https://MYWEB.sharepoint.com/sites/MYSITE/_api/web/SiteGroups/GetById(" & Number.ToText( Offset ) & ")/Users"
    )
    )
    in
    Source
    in
    Source

    - then i call this function with insert a new column INVOKE CUSTOM FUNCTION and using a column of the same table (the id of the groups) as parameter of the function.
    - then i arrange the data to obtain what i need: extract the users id from the results.


    This post help me to resolve:
    https://community.fabric.microsoft.com/t5/Community-Blog/Use-Column-as-Parameter-for-Custom-Function-in-Power-Query/ba-p/1495277

    Thank you every body i put it as a solution.
    See you next time!