Update Global Microsoft 365 Group Settings
Configuring Microsoft 365 Group settings is essential for ensuring a secure and compliant environment. This script can be utilized to set up different group settings, such as naming policies and guest access.
Summary
Managing Microsoft 365 Group settings is crucial for maintaining a compliant and secure environment.PowerShell and Microsoft Graph can be used to configure various group settings, including naming policies, guest access, and more.
As a regular user of PnP PowerShell, I wanted to replicate the Microsoft Entra cmdlets for configuring group settings using PnP PowerShell.
Prerequisites
- PnP PowerShell https://pnp.github.io/powershell/
- The user account that runs the script must have Global Admin administrator access or Entra ID Admin role.
param (
[Parameter(Mandatory = $true)]
[string] $domain
)
Clear-Host
$adminSiteURL = "https://$domain-Admin.SharePoint.com"
Connect-PnPOnline -Url $adminSiteURL
$BlockedWords = @("law","pension","finance","sea","ocean","river","lake","stream","creek","pond","pool","reservoir","dam","canal","ditch","drain","gutter","sewer","pipe","tube","hose","conduit","channel","aqua")
$unifiedSet = Get-PnPMicrosoft365GroupSettings -GroupSetting "Group.Unified"
$url = "/groupSettings/$($unifiedSet.Id)"
$Payload = @"
{
"values": [
{
"name": "CustomBlockedWordsList",
"value": "$($BlockedWords -join ',')"
},
{
"name": "PrefixSuffixNamingRequirement",
"value": "Test_[Department][GroupName][Office]"
}
,
{
"name": "AllowToAddGuests",
"value": "True"
},
{
"name": "AllowGuestsToBeGroupOwner",
"value": "False"
},
{
"name": "AllowGuestsToAccessGroups",
"value": "True"
},
{
"name": "AllowToAddGuests",
"value": "True"
},
{
"name": "EnableGroupCreation",
"value": "True"
},
{
"name": "NewUnifiedGroupWritebackDefault",
"value": "True"
},
{
"name": "EnableMIPLabels",
"value": "True"
},
{
"name": "EnableMSStandardBlockedWords",
"value": "False"
}
]
}
"@
Invoke-PnPGraphMethod -Url $url -Method Patch -Content $Payload
(Get-PnPMicrosoft365GroupSettings -GroupSetting "Group.Unified").Values Source Credit
Sample first appeared on Managing Microsoft 365 Group Settings with PnP PowerShell and Microsoft Graph
Contributors
| Author(s) |
|---|
| Reshmee Auckloo |
Disclaimer
THESE SAMPLES ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
Tool documentation & references
- Want to learn more about PnP PowerShell and the cmdlets
Check out the PnP PowerShell site to get started and for the reference to the cmdlets.