Set Office 365 Group Privacy to Private or Public using PowerShell

Requirement: Change Office 365 Group Privacy to Private or Public.

How to Change Office 365 Group Privacy?

If you’re using a Microsoft 365 group to collaborate with others, it’s crucial to understand how to change the privacy setting. By default, the privacy is set to public, which means that anyone in your organization can find and join the group. If you want to keep the group private so that only specific people can join and only members can access the group, you’ll need to change the group’s privacy setting. In this article, we’ll show you how to change Microsoft 365 Group privacy from public to private (or vice versa!)

You can change the Office 365 group’s privacy through the Microsoft 365 admin center as an admin. Here is how:

  1. Log in to the Microsoft 365 Admin Center site: https://admin.microsoft.com
  2. Expand “Teams & Groups” and Click on “Active Teams & Groups” in the left navigation.
  3. Search and select the Office 365 group you wish to change the privacy settings.
  4. Click on the settings tab, and then select the privacy to “Private” or “Public”.
  5. Click on “Save” to commit your changes. You should see the “Changes saved” message.
    change office 365 group privacy to private or public using powershell

PnP PowerShell to Change the Microsoft 365 Group Privacy

Let’s change a Microsoft 365 group from Private to Public using PnP PowerShell:

#Config Variables
$AdminSiteURL = "https://crescent-admin.sharepoint.com"
$GroupEmail = "[email protected]"

Try {
    #Connect to PnP Online
    Connect-PnPOnline -Url $AdminSiteURL -Interactive

    #Get the Office 365 Group from Email
    $Group = Get-PnPMicrosoft365Group | Where Mail -eq $GroupEmail

    #Check if group exists
    If($Group -ne $Null)
    {
        #Set the Group Privacy to Public
        Set-PnPMicrosoft365Group -Identity $Group -IsPrivate:$False
        Write-Host "Group Privacy Updated Successfully!" -f Green
    }
    Else
    {
        Write-host "Could not Find Group!" -f Yellow
    }
}
Catch {
    write-host -f Red "Error:" $_.Exception.Message
}

Set Office 365 Group Privacy to Private or Public using PowerShell:

Let’s change the privacy of the “[email protected]” group to “Private”.

#Get Credentials to connect
$Credential = Get-Credential
 
#Connect to Exchange Online
Connect-ExchangeOnline -Credential $Credential -ShowBanner:$False

#Set Office 365 group's privacy to "Private"
Set-UnifiedGroup -Identity "[email protected]" -AccessType Private

#Disconnect Exchange Online
Disconnect-ExchangeOnline -Confirm:$False

Similarly, you can change the group type to “Public” as:

Set-UnifiedGroup -Identity "[email protected]" -AccessType Public

To change a SharePoint Online site privacy, use: How do I make a SharePoint site public to everyone?

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

2 thoughts on “Set Office 365 Group Privacy to Private or Public using PowerShell

Leave a Reply

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