Sharepoint - Disallow Classic Team Sites to Join Office 365 Groups
To actually disable this, go to the classic settings page:
https://contoso-admin.sharepoint.com/_layouts/15/online/TenantSettings.aspx
About in the middle you will find this one:
Control whether site collection administrators can use the "Connect to a new Office 365 Group" command on the Settings menu to connect classic team sites to new Office 365 groups
This setting has two options:
- Prevent site collection administrators from connecting sites to new Office 365 groups
- Allow site collection administrators to connect sites to new Office 365 groups
Standard is second, for your requirement - set it to the first one.
There is a hidden GroupifyMenuButton feature that is responsible for hiding and showing the "Connect to new Office 365 Group" button.
This action button redirects to the following URL when we click it: /_layouts/15/creategroup.aspx?mode=connectgroup URL
We can disable this feature with the following Powershell PnP code:
Connect-PnPOnline -url "https://contoso.sharepoint.com/sites/ClassicTeamSite"
$GroupifyFeature = "5007df5b-1eea-49f8-9c02-5debc81ce3f2"
Disable-PnPFeature -Identity $GroupifyFeature
Result
If we want to add the button back to the site settings, we can activate the feature again:
Enable-PnPFeature $GroupifyFeature