Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Office 365 Groups Creation
# For more information see: http://askwictor.com/2jxcYDT
# Store the credentials in a variable
$creds = Get-Credential
# Connect to the Microsoft Online services
Connect-MsolService -Credential $creds
# Get tenant setting (misspelled)
Get-MsolCompanyInformation | Format-List UsersPermissionToCreateGroupsEnabled
# If false, then use the following
Set-MsolCompanySettings -UsersPermissionToCreateGroupsEnabled $true
# Retrieve ID of Group that should have the option to create groups
$group = Get-MsolGroup -SearchString "Group creators"
# Retrieve the Group.Unified settings template (assuming you have not done this before)
$template = Get-MsolAllSettingTemplate | Where-Object {$_.DisplayName -eq "Group.Unified"}
# Create the settings object from the template
$settings = $template.CreateSettingsObject()
# Use this settings object to prevent others than specified group to create Groups
$settings["EnableGroupCreation"] = $false
$settings["GroupCreationAllowedGroupId"] = $groupd.ObjectId
# (optional) Add a link to the Group usage guidelines
$settings["UsageGuidelinesUrl"] = "https://contoso.sharepoint.com/Pages/GroupUsageGuidelines.aspx"
# (optional) Add a link to Guest usage guidelines
$settings["GuestUsageGuidelinesUrl"] = "http://contoso.com/usageguidelines"
# (optional) Add classifications to be used for Groups
$settings["ClassificationList"] = "Public,Internal,Top Secret"
# Verify
$settings.Values
# Add the settings to Azure AD
New-MsolSettings -SettingsObject $settings
#################
# Retrieve settings, if already created
$settings = Get-MsolAllSettings | Where-Object {$_.DisplayName -eq "Group.Unified"}
# Check the values
$settings.Values
# Update a property
$settings["GuestUsageGuidelinesUrl"] = "http://www.wictorwilen.se"
# Save the updates
Set-MsolSettings -SettingId $settings.ObjectId -SettingsValue $settings.GetSettingsValue()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment