SOLVED

O365 Report | Groups users belong to

%3CLINGO-SUB%20id%3D%22lingo-sub-2323589%22%20slang%3D%22en-US%22%3EO365%20Report%20%7C%20Groups%20users%20belong%20to%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2323589%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20need%20to%20generate%20an%20excel%20list%20with%20users%20and%20the%20corresponding%20groups%20they%20belong%20to%20like%3A%3C%2FP%3E%3CP%3Euser1%2Cgroup1%2Cgroup2%2Cgroup3%3C%2FP%3E%3CP%3Euser2%2Cgroup1%2Cgroup4%3C%2FP%3E%3CP%3E....%3C%2FP%3E%3CP%3EHow%20can%20I%20get%20this%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2FBrgds%3C%2FP%3E%3CP%3Ejoao%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2323589%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2324947%22%20slang%3D%22en-US%22%3ERe%3A%20O365%20Report%20%7C%20Groups%20users%20belong%20to%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2324947%22%20slang%3D%22en-US%22%3EThere%20are%20plenty%20such%20scripts%20available%20online%2C%20find%20the%20one%20that%20best%20suits%20your%20needs%20and%20modify%20it%20as%20needed.%20Here's%20one%20of%20mine%3A%20%3CA%20href%3D%22https%3A%2F%2Fwww.michev.info%2FBlog%2FPost%2F2250%2Fgenerating-a-report-of-users-group-membership-memberof-inventory%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.michev.info%2FBlog%2FPost%2F2250%2Fgenerating-a-report-of-users-group-membership-memberof-inventory%3C%2FA%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2328322%22%20slang%3D%22en-US%22%3ERe%3A%20O365%20Report%20%7C%20Groups%20users%20belong%20to%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2328322%22%20slang%3D%22en-US%22%3EHi%20Vasil%2C%3CBR%20%2F%3EI%20got%20the%20following%20error%3A%3CBR%20%2F%3E%3CBR%20%2F%3EPS%20C%3A%5Ctemp%26gt%3B%20.%5CGroupMembership%3CBR%20%2F%3E%3CBR%20%2F%3EPowerShell%20credential%20request%3CBR%20%2F%3EEnter%20your%20credentials.%3CBR%20%2F%3EUser%3A%20xxxxxxxxxxxxxxxxxxxxx%3CBR%20%2F%3EPassword%20for%20user%20joao.casqueiro%40cascais.onmicrosoft.com%3A%20****************%3CBR%20%2F%3E%3CBR%20%2F%3EWARNING%3A%20The%20names%20of%20some%20imported%20commands%20from%20the%20module%20'tmp_ezdrmpwi.sjb'%20include%20unapproved%20verbs%20that%20might%20make%20them%20less%20discoverable.%20To%20find%20the%20commands%20with%20unapproved%20verbs%2C%20run%20the%20Import-Module%20command%20again%20with%20the%20Verbose%20parameter.%20For%20a%20list%20of%20approved%20verbs%2C%20type%20Get-Verb.%3CBR%20%2F%3EGet-Recipient%3A%20The%20operation%20couldn't%20be%20performed%20because%20object%20'gosho'%20couldn't%20be%20found%20on%20'VI1P193A001DC06.EURP193A001.PROD.OUTLOOK.COM'.%3CBR%20%2F%3EWrite-Error%3A%20C%3A%5Ctemp%5CGroupMembership.ps1%3A124%3CBR%20%2F%3ELine%20%7C%3CBR%20%2F%3E124%20%7C%20Get-DGMembershipInventory%20%40PSBoundParameters%20-OutVariable%20global%3AvarD%20%E2%80%A6%3CBR%20%2F%3E%7C%20~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%3CBR%20%2F%3E%7C%20No%20users%20of%20the%20specifyied%20types%20were%20found%2C%20specify%20different%20criteria.%3CBR%20%2F%3E%3CBR%20%2F%3EPS%20C%3A%5Ctemp%26gt%3B%3CBR%20%2F%3E%3CBR%20%2F%3ECan%20you%20help%3F%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%2FBrgds%3CBR%20%2F%3Ejoao%3C%2FLINGO-BODY%3E
Occasional Contributor

Hi,

 

I need to generate an excel list with users and the corresponding groups they belong to like:

user1,group1,group2,group3

user2,group1,group4

....

How can I get this?

 

Thanks/Brgds

joao

4 Replies
best response confirmed by Joao Casqueiro (Occasional Contributor)
Solution
There are plenty such scripts available online, find the one that best suits your needs and modify it as needed. Here's one of mine: https://www.michev.info/Blog/Post/2250/generating-a-report-of-users-group-membership-memberof-invent...
Hi Vasil,
I got the following error:

PS C:\temp> .\GroupMembership

PowerShell credential request
Enter your credentials.
User: xxxxxxxxxxxxxxxxxxxxx
Password for user joao.casqueiro@cascais.onmicrosoft.com: ****************

WARNING: The names of some imported commands from the module 'tmp_ezdrmpwi.sjb' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.
Get-Recipient: The operation couldn't be performed because object 'gosho' couldn't be found on 'VI1P193A001DC06.EURP193A001.PROD.OUTLOOK.COM'.
Write-Error: C:\temp\GroupMembership.ps1:124
Line |
124 | Get-DGMembershipInventory @PSBoundParameters -OutVariable global:varD …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| No users of the specifyied types were found, specify different criteria.

PS C:\temp>

Can you help?

Thanks/Brgds
joao
Uh, that's on me, seems I forgot to clean up the script after doing some tests. You can remove "gosho" from line 78, or just redownload the updated script version.