List all Office365 Groups and Distribution Lists that has a certain domain

%3CLINGO-SUB%20id%3D%22lingo-sub-436727%22%20slang%3D%22en-US%22%3EList%20all%20Office365%20Groups%20and%20Distribution%20Lists%20that%20has%20a%20certain%20domain%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-436727%22%20slang%3D%22en-US%22%3E%3CP%3EHi%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20have%20Office365%20and%20have%20multiple%20domains%20attached%20to%20it%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20want%20to%20be%20able%20to%20run%20a%20script%20that%20lists%20all%20the%20Office365%20groups%20and%20distribution%20lists%20that%20have%20this%20domain%20attached%20to%20it%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnyone%20know%20what%20command%20we%20need%20to%20run%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECheers%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-436727%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExchange%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-438966%22%20slang%3D%22en-US%22%3ERe%3A%20List%20all%20Office365%20Groups%20and%20Distribution%20Lists%20that%20has%20a%20certain%20domain%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-438966%22%20slang%3D%22en-US%22%3E%3CP%3EEasiest%20way%20is%20via%20the%20%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%20box-sizing%3A%20border-box%3B%20color%3A%20%23333333%3B%20font-family%3A%20%26amp%3Bquot%3B%20segoeui%26amp%3Bquot%3B%2C%26amp%3Bquot%3Blato%26amp%3Bquot%3B%2C%26amp%3Bquot%3Bhelvetica%20neue%26amp%3Bquot%3B%2Chelvetica%2Carial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3EGet-AzureADDomainNameReference%3C%2FFONT%3E%20cmdlet%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3EGet-AzureADDomainNameReference%20-Name%20domain.com%20%7C%20%3F%20%7B%24_.ObjectType%20-eq%20%22Group%22%7D%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3EThe%20of%20course%20it%20depends%20on%20the%20definition%20of%20group%2C%20the%20definition%20of%20%22attached%20to%22%2C%20and%20so%20on...%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Contributor

Hi

 

We have Office365 and have multiple domains attached to it

 

We want to be able to run a script that lists all the Office365 groups and distribution lists that have this domain attached to it

 

Anyone know what command we need to run

 

Cheers

1 Reply
Highlighted

Easiest way is via the Get-AzureADDomainNameReference cmdlet:

 

Get-AzureADDomainNameReference -Name domain.com | ? {$_.ObjectType -eq "Group"}

 

The of course it depends on the definition of group, the definition of "attached to", and so on...