Skip to content

Instantly share code, notes, and snippets.

@joerodgers
Created June 3, 2024 14:48
Show Gist options
  • Save joerodgers/8e1e3201dd2930e118d6ec20bc56e8a2 to your computer and use it in GitHub Desktop.
Save joerodgers/8e1e3201dd2930e118d6ec20bc56e8a2 to your computer and use it in GitHub Desktop.
Example script to hide the "Teamify" Dialog box on all M365 group connected sites
#requires -modules "PnP.PowerShell"
# permission requirements
# - Microsoft Graph > Application > one of Directory.Read.All, Directory.ReadWrite.All, Group.Read.All, Group.ReadWrite.All, GroupMember.Read.All, GroupMember.ReadWrite.All
# - SharePoint > Application > Sites.FullControl.All
Connect-PnPOnline `
-Url "https://$env:O365_TENANT-admin.sharepoint.com" `
-ClientId $env:O365_CLIENTID `
-Thumbprint $env:O365_THUMBPRINT `
-Tenant $env:O365_TENANTID `
-ErrorAction Stop
$m365GroupsWithNoTeam = Get-PnPMicrosoft365Group -IncludeSiteUrl | Where-Object -Property HasTeam -eq $false
$createdDate = [DateTime]::Today.AddDays( -10 ) # adjust as needed
foreach( $group in $m365GroupsWithNoTeam )
{
if( $group.CreatedDateTime -gt $createdDate )
{
Connect-PnPOnline `
-Url $group.SiteUrl `
-ClientId $env:O365_CLIENTID `
-Thumbprint $env:O365_THUMBPRINT `
-Tenant $env:O365_TENANTID `
-ErrorAction Stop
Set-PnPSite -NoScriptSite $false
Set-PnPPropertyBagValue -Key "TeamifyHidden" -Value "TRUE" #
Set-PnPSite -NoScriptSite $true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment