Reactivate the option to create Team from the SharePoint Team Site

When we create a Modern Team site, we have the possibility to create with a simple click, since we have an Office 365 group, a Team inside the Microsoft Teams. However, if that message was dismissed by any admin of the site and you need to create the group, they need to do other type configurations to activate that group.

With the next PowerShell Script, we will reactivate this functionality for the SharePoint Team sites which doesn’t have this panel shows. Then within a click, the admin of the site can create the Team.
On the script, I’ve included the possibility to dismiss this option on all the sites. It’s required to activate the Custom Scripts on the site to reactivate/deactivate this option which at the end of the process it will be deactivated. If the user is not admin of the SharePoint Team site, it’ll show an error saying not authorized to adjust the property bags.

$tenant     = "https://contoso-admin.sharepoint.com" #SharePoint Admin Center
$username   = "contoso@contoso.onmicrosoft.com"
$password   = "password"

$encpassword = convertto-securestring -String $password -AsPlainText -Force
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $encpassword

Connect-PnPOnline -Url $tenant -Credentials $cred
$sites = Get-PnPTenantSite -Detailed -Template 'GROUP#0'	

$ReadHost = Read-Host "Do you want to Show the option to Create a Team on Microsoft Teams? (y|n)"
foreach($site in $sites){
 Write-Host $site.Url -NoNewline
 if($site.DenyAddAndCustomizePages -ne 'Disabled') {
  $site.DenyAddAndCustomizePages = [Microsoft.Online.SharePoint.TenantAdministration.DenyAddAndCustomizePagesStatus]::Disabled
  $site.Update() |Out-Null
  $site.Context.ExecuteQuery() |Out-Null
}

Connect-PnPOnline $site.Url -Credentials $cred
if($ReadHost -match 'n'){
 Set-PnPPropertyBagValue -Key TeamifyHidden -Value True
 Write-Host "---- Hidden on SharePoint"  -BackgroundColor Green -ForegroundColor Black
}else{
 Remove-PnPPropertyBagValue -Key 'TeamifyHidden' -Force
 Write-Host "---- Visible on SharePoint"  -BackgroundColor Green -ForegroundColor Black
}
Connect-PnPOnline -Url $tenant -Credentials $cred
$site.DenyAddAndCustomizePages = [Microsoft.Online.SharePoint.TenantAdministration.DenyAddAndCustomizePagesStatus]::Enabled
$site.Update()|Out-Null
$site.Context.ExecuteQuery()|Out-Null	
}

Conclusion

After this script is run, it’ll update all your SharePoint Team sites with the option to create the team on Microsoft Teams or to hide it. You can also adjust it to just a site if you wish to make that for only a SharePoint Site. If the team is already on Microsoft Teams, this option will never be visible on the site.

2 Comments

  1. Simon said:

    How do I adapt this to HIDE the banner?

    March 27, 2020
    Reply
    • David Ramalho said:

      Hi Simon,

      When running the code you need to select the option(n) to not show this. The line of code that does it is:

      Remove-PnPPropertyBagValue -Key 'TeamifyHidden' -Force

      April 7, 2020
      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *