- Notifications
You must be signed in to change notification settings - Fork 187
/
Copy pathGet-TeamMembers.ps1
29 lines (25 loc) · 1.02 KB
/
Get-TeamMembers.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Replace with your ClientId
# Replace with your TenantId
# Replace with your Cert subject
Connect-Graph-ClientId "YOUR_CLIENT_ID"`
-TenantId "YOUR_TENANT_ID"`
-CertificateName "YOUR_CERTIFICATE_NAME"
# Install beta SDK to use these samples.
$groups=Get-MgBetaGroup
$teams=$groups|Where-Object { $_.ResourceProvisioningOptions-Contains"Team" }
# List owners and memebers of all Teams team in your tenant.
foreach($teamin$teams) {
Write-Host"Team: "+$team.DisplayName-ForegroundColor Blue
Write-Host"Owners: "-ForegroundColor Yellow
$owners=Get-MgBetaGroupOwner-GroupId $team.Id
foreach($ownerin$owners) {
$o=Get-MgBetaUser-UserId $owner.Id
Write-Host$o.DisplayName-ForegroundColor Yellow
}
Write-Host"Members: "-ForegroundColor Green
$members=Get-MgBetaGroupMember-GroupId $team.Id
foreach($memberin$members) {
$u=Get-MgBetaUser-UserId $member.Id
Write-Host$u.DisplayName-ForegroundColor Green
}
}