-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #755 from Tanddant/main
🔨 - Added teams-list-ownerless-teams sample
- Loading branch information
Showing
3 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
plugin: add-to-gallery | ||
--- | ||
|
||
# List Ownerless Teams | ||
|
||
## Summary | ||
|
||
If your organization has been using Microsoft Teams for more that a few years, you'll no doubt have a number of Teams that have been orphaned, probably because the original owner has moved on. This script will list all Teams that have fewer than a specified number of owners, and export them to a CSV file. | ||
|
||
# [PnP PowerShell](#tab/pnpps) | ||
|
||
```powershell | ||
Connect-PnPOnline -ClientId "GUID" -Tenant "GUID" -CertificatePath -CertificatePassword "Password" | ||
$MinimumRequiredOwners = 1; | ||
$Groups = Get-PnPMicrosoft365Group -IncludeOwners | Where-Object {$_.Owners.Count -le $MinimumRequiredOwners -and $_.HasTeam} | ||
$MappedObjects = [System.Collections.ArrayList]@() | ||
foreach ($Group in $Groups) { | ||
$MappedObject = [PSCustomObject]@{ | ||
GroupId = $Group.GroupId | ||
DisplayName = $Group.DisplayName | ||
OwnersCount = $Group.Owners.Count | ||
Owners = $Group.Owners | Select-Object -Property "Email" | Join-String -Property "Email" -Separator "; " | ||
} | ||
$MappedObjects += $MappedObject | ||
} | ||
$fileName = "$(Get-Date -Format ("yyyy-MM-dd"))-GroupsWithFewerThan$($MinimumRequiredOwners)Owners.csv"; | ||
$MappedObjects | Select-Object -Property * | Export-Csv -Path ".\$fileName" -Encoding UTF8 -Delimiter ";" -Force; | ||
``` | ||
|
||
## Contributors | ||
|
||
| Author(s) | | ||
|-----------| | ||
| [Dan Toft](https://Dan-Toft.dk) | | ||
|
||
|
||
[!INCLUDE [DISCLAIMER](../../docfx/includes/DISCLAIMER.md)] | ||
<img src="https://m365-visitor-stats.azurewebsites.net/script-samples/scripts/teams-list-ownerless-teams" aria-hidden="true" /> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
[ | ||
{ | ||
"name": "teams-list-ownerless-teams", | ||
"source": "pnp", | ||
"title": "List ownerless teams", | ||
"shortDescription": "Easily identify ownerless teams in your tenant", | ||
"url": "https://pnp.github.io/script-samples/teams-list-ownerless-teams/README.html", | ||
"longDescription": [ | ||
"Once an employee leaves, and their account is disabled, the ownership of the Microsoft 365 Group (and the associated Microsoft Teams team) is lost. This script helps you to identify all the teams that have no owner, so you can take the necessary actions to assign a new owner to the team." | ||
], | ||
"creationDateTime": "2024-10-10", | ||
"updateDateTime": "2024-10-10", | ||
"products": [ | ||
"Teams" | ||
], | ||
"metadata": [ | ||
{ | ||
"key": "PNP-POWERSHELL", | ||
"value": "2.2.51" | ||
}, | ||
{ | ||
"key": "POWERSHELL", | ||
"value": "7.4.5" | ||
} | ||
], | ||
"categories": [ | ||
"Report" | ||
], | ||
"tags": [ | ||
"Connect-PnPOnline", | ||
"Get-PnPMicrosoft365Group" | ||
], | ||
"thumbnails": [ | ||
{ | ||
"type": "image", | ||
"order": 100, | ||
"url": "https://raw.githubusercontent.com/pnp/script-samples/main/scripts/teams-list-ownerless-teams/assets/preview.png", | ||
"alt": "List ownerless teams" | ||
} | ||
], | ||
"authors": [ | ||
{ | ||
"gitHubAccount": "Tanddant", | ||
"company": "Evobis ApS", | ||
"pictureUrl": "https://github.com/tanddant.png", | ||
"name": "Dan Toft" | ||
} | ||
], | ||
"references": [ | ||
{ | ||
"name": "Want to learn more about PnP PowerShell and the cmdlets", | ||
"description": "Check out the PnP PowerShell site to get started and for the reference to the cmdlets.", | ||
"url": "https://aka.ms/pnp/powershell" | ||
} | ||
] | ||
} | ||
] |