Last active
September 29, 2015 11:04
-
-
Save alexinnes/c8e8933f8b3bcee72fd6 to your computer and use it in GitHub Desktop.
O365 Getting users from all groups
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Run this first - It will ask you to login (microsoft account) | |
Connect-MsolService | |
#This gets the domain | |
$domain = Get-MsolPartnerContract -DomainName #change me to the domain name e.g. someone.onmicrosoft.com | |
#this gets the users in the group | |
$groups = @(Get-MsolGroup -TenantId $domain.TenantId) | |
#This goes through the groups and lists the users. | |
foreach($element in $groups){$element.DisplayName; Get-MsolGroupMember -TenantId $domain.TenantId -GroupObjectId $element.ObjectID} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment