Epic Visio Skills produced this cool illustration of Microsoft Teams extensibility!

How to fix a Teams team with no Owners?

This post was most recently updated on September 11th, 2020.

Reading Time: 4 minutes.

As Teams adoption grows (partially driven by the megatrend of digitalization, partially by the massive surge in working from home due to Covid-19), different problems managing Teams also become more obvious. The growth seems to have been largely organic. Teams and organizations are adopting the tools that best help them get their work done with little regard to how the tools are maintained and best used.

Teams are often created as needed, and by whoever needs them. The creator also becomes the owner – often, the sole owner – of the team. But what if they leave the organization?

Their teams become orphaned, and there’s very little any of the members can do to administer the team. For teams that are actively in use, being unable to add new members, configure new channels or register new apps might completely cripple them.

This makes orphaned teams a pretty big problem.

Oh – by the way. If you’re working from home, check out my top tips for staying sane from the article below:

What to do, then?

Teams are actually powered by the Office Groups, and the permission model (for the time being, at least) is also coming straight from the Groups. Office Group members are also members of the Teams team, and Office Group owners are also owners of the Teams team.

Hence, the fix is pretty much the same as for just the “vanilla” Office Groups. I’m describing the scripted solution in this article, but you can also check a longer description of pretty much the same script in the article below:

However, since the terminology and the use case is just a bit different, I’m describing the steps also below!

Solution

You can use PowerShell to add a new owner to an “unified group” – which is the name Exchange Online uses for Office Groups, which in turn power the permissions for Microsoft Teams -teams.

Don’t want to read through the whole thing? I’ve got a full script ready for you. Just jump to the script by clicking this!

Time needed: 10 minutes.

How to add a new Owner to a Microsoft Teams team using PowerShell

  1. Open Powershell (don’t use SharePoint Online Management Shell)

    At least I had to run it as an admin. Don’t use SharePoint Online Management Shell – you never know if some of the imported commandlet names might conflict!

  2. Store your credentials

    $cred = Get-Credential

    This opens a login window, where you can give your admin credentials.

  3. Establish a session with Exchange Online

    $session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $cred -Authentication Basic -AllowRedirection

    The ConnectionUri is the same for all tenants! Don’t change it.
    Then import the established session:

    Import-PSSession $session

    Executing this command should actually take a while, as PowerShell is importing a lot of commandlets here. After it’s done, you are able to run the next command. If you aren’t, you’ll need to make sure you have enough permissions on the account you’re using!

  4. Figure out the alias of your group (you’ll need it in a sec)

    Running something like this gets you only the “orphaned” groups (without a single owner). Exchange Online calls Office Groups UnifiedGroups. That might be a bit confusing, but it’s very fitting for their role as the one, unifying the access to all different Microsoft’s tools in Office 365!

    $Groups = Get-UnifiedGroup | Where-Object {([array](Get-UnifiedGroupLinks -Identity $_.Id -LinkType Owners)).Count -eq 0} | Select Id, Alias, DisplayName, ManagedBy, WhenCreated

    ForEach ($G in $Groups) {
    Write-Host "Warning! The following group has no owner:" $G.Alias
    }


    This magic command shows only the Office 365 Groups without Owners. In this case, there's just one, and it's properties are shown nicely.

    This magic command shows only the Office 365 Groups without Owners. In this case, there’s just one, and it’s properties are shown nicely.

  5. Add your account (or any other) as a member of the group, then as the owner

    This order of commands is required – only members can also be owners! See the commands below – they’ll yield no output if successful:

    Add-UnifiedGroupLinks [alias_from_above] -Links [your_upn] -LinkType Member
    Add-UnifiedGroupLinks [alias_from_above] -Links [your_upn] -LinkType Owner

  6. Verify, that the operation was successful

    You can verify the success by querying for your group:

    Get-UnifiedGroup -Identity [alias_again] | Select Alias,ManagedBy

    This should produce your group with your account in the “ManagedBy” column.

    Alternatively, of course you can just query all orphaned groups again!

The End Game: Add yourself as the owner of all orphaned groups

So, taking what we’ve learned today, in short, this is the script you can use to add yourself as the owner of all the orphaned Office 365 Groups:

 
$cred = Get-Credential
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $cred -Authentication Basic -AllowRedirection

Import-PSSession $session

$groups = Get-UnifiedGroup | Where-Object {([array](Get-UnifiedGroupLinks -Identity $_.Id -LinkType Owners)).Count -eq 0} | Select Id, Alias, DisplayName, ManagedBy, WhenCreated
ForEach ($g in $groups) { 
	Add-UnifiedGroupLinks $g.Alias -Links $cred.UserName -LinkType Member
	Add-UnifiedGroupLinks $g.Alias -Links $cred.UserName -LinkType Owner
} 

Hope this helps :) As usual, I welcome any and all feedback in the comments -section below!

mm
0 0 vote
Article Rating
Subscribe
Notify of
guest
2 Comments
most voted
newest oldest
Inline Feedbacks
View all comments