Use PowerShell to manage Office 365 Groups - Admin help

Groups in Office 365 are intended to be created and managed by admin and end users. If you, the global administrator, need to perform bulk operations, configure global settings, or want to monitor Group activity from the command line, you can use Windows PowerShell and the following cmdlets to accomplish those tasks. Check out Learn more about groups for more information about groups in Office 365.

If you're new to Windows PowerShell, see Scripting with Windows PowerShell.

New Office 365 Groups cmdlets

The following cmdlets were recently made available to Office 365 Groups. If you aren't able to use these, your Office 365 subscription has not been updated with this functionality yet. Check your Message Center and the Office 365 Roadmap.

Cmdlet name

Description

Get-UnifiedGroup

Use this cmdlet to look up existing Office 365 groups, and to view properties of the group object.

Set-UnifiedGroup

Update the properties of a specific Office 365 group.

New-UnifiedGroup

Create a new Office 365 group. This cmdlet provides a minimal set of parameters, for setting values for extended properties use Set-UnifiedGroup after creating the new group.

Remove-UnifiedGroup

Delete an existing Office 365 group.

Get-UnifiedGroupLinks

Retrieve membership and owner information for an Office 365 group.

Add-UnifiedGroupLinks

Add members and owners to an existing Office 365 group.

Remove-UnifiedGroupLinks

Remove owners and members from an existing Office 365 group.

Migrate your distribution groups (distribution lists) to Office 365 groups

If you have distribution groups and you want them to get all the features and functionality of Office 365 groups, you can update your distribution groups to Office 365 groups. Check out these topics for more info:

Link to your Office 365 groups usage guidelines

Use the Azure Active Directory PowerShell to point your users to your organization's usage guidelines for Office 365 groups. Check out, Azure Active Directory cmdlets for configuring group settings and follow the steps in the Create settings at the directory level to define the usage guideline hyperlink. Once you run the AAD cmdlet, user's will see a link to your organization's usage guidelines when they create or edit a group in Outlook.

Create a new group with usage guidelines link

Click Group usage guidelines to see your organizations Office 365 groups guidelines

Create classifications for Office groups in your organization

You can create classifications that the users in your organization can set when they create an Office 365 group. For example, you can allow users to set “Standard”, “Secret”, and “Top Secret" on groups they create. Group classifications aren't set by default and you need to create it in order for your users to set it. Use Azure Active Directory PowerShell to point your users to your organization's usage guidelines for Office 365 groups. Check out, Azure Active Directory cmdlets for configuring group settings and follow the steps in the Create settings at the directory level to define the classification for Office 365 groups.

After you run the above Azure Active Directory cmdlet to set your classification, run the Set-UnifiedGroup cmdlet if you want to set the classification for a specific group.

Set-UnifiedGroup <LowImpactGroup@constoso.com> -Classification <LowImpact> 

Or create a new group with a classification.

New-UnifiedGroup <HighImpactGroup@constoso.com> -Classification <HighImpact> -AccessType <Public> 

Check out Using PowerShell with Exchange Online and Connect to Exchange Online PowerShell for more details on using Exchange Online PowerShell.

Once these settings are enabled, the group owner will be able to choose a classification from the drop down menu in Outlook on the Web and Outlook, and save it from the Edit group page.

Choose Office 365 group classification

Allow users to send as the Office 365 group

If you want to enable your Office 365 groups to "Send As", use the Add-RecipientPermission and the Get-RecipientPermission cmdlets to configure this. Once you enable this setting, Office 365 group users can use Outlook or Outlook on the web to send and reply to email as the Office 365 group. Users can go to the group, create a new email, and change the "Send As" field to the groups email address.

Note: You'll need to add the group email address to the Cc field when you compose the “send as” email, so that the messages show up in group conversations.

At this time, the only way to update the mailbox policy is through Windows PowerShell.

  • Use this command to set the group alias.

    $groupAlias = "TestSendAs"
  • Use this command to set the user alias.

    $userAlias = "User"
  • Use this command to pass the groupalias to the Get-Recipient cmdlet to get the recipient details.

    $groupsRecipientDetails = Get-Recipient -RecipientTypeDetails groupmailbox -Identity $groupAlias
  • Then the target recipient name (Group name) needs to be passed to the Add-RecipientPermission cmdlet. The useralias for whom the sendas permission will be given will be assigned to the -Trustee parameter.

    Add-RecipientPermission -Identity $groupsRecipientDetails.Name -Trustee $userAlias -AccessRights SendAs
  • Once the cmdlet is executed, users can go to Outlook or Outlook on the web to send as the group, by adding the group email address to the From field.

Manage external sharing for Office 365 Group site collections

By default, all SharePoint site collections that are part of an Office 365 Group have the sharing setting set to Allow sharing only with the external users that already exist in your organization’s directory. To change this setting, you can use the Set-SPOSite Windows PowerShell cmdlet.

Example:

Set-SPOSite -Identity https://contoso.sharepoint.com/sites/site1 -SharingCapability -ExternalUserSharingOnly 

This example updates the external sharing capability of the site collection "https://contoso.sharepoint.com/sites/site1" to allow sharing with authenticated external users. This cmdlet is executed immediately.

To view the existing sharing setting, use the Get-SPOSite Windows PowerShell cmdlet.

Example:

(Get-SPOSite -Identity https://contoso.sharepoint.com/sites/site1).SharingCapability

For detailed information about these cmdlets and their parameters in Windows PowerShell, see Set-SPOSite and Get-SPOSite.

Adding Quota Setting for Group Sites

If you want to manage storage in Office 365 groups and set quotas on how much space is allocated to groups, then use the Get-SPOSite cmdlet to set a quota on a group site. At this time, the only way to update the mailbox policy is through Windows PowerShell. The following example gets and sets the quota storage for a site in the Contoso domain.

  1. Run this command to get quota details for a group site:

    Get-SPOSite –Identity https://contoso.sharepoint.com/sites/<groupname> -detailed |fl
  2. Run this command to set quota for the site:

    Note: Before using the Set-SPOSite command, your site collection storage management must be set to Manual and not use pooled storage. Learn more in Manage site collection storage limits.

    Set-SPOSite –Identity https://contoso.sharepoint.com/sites/<groupname> -StorageQuota 3000 -StorageQuotaWarningLevel 2000

Verify that the set action worked by running the Get-SPOSite cmdlet again and verifying the storage quota has been updated. Make sure you switch site collection storage management setting back to Automatic if that was the original setting.

Groups Photo cmdlets

Cmdlet name

Description

Get-UserPhoto

Used to view information about the user photo associated with an account. User photos are stored in Active Directory.

Set-UserPhoto

Used to associate a user photo with an account. User photos are stored in Active Directory.

Remove-UserPhoto

Remove the photo for an Office 365 group.

Control Office 365 Group creation

For information about controlling Office 365 Group creation, check out Manage Office 365 Group Creation

For more information

Share Facebook Facebook Twitter Twitter Email Email

Was this information helpful?

Great! Any other feedback?

How can we improve it?

Thank you for your feedback!

×