Set newly created Groups SharePoint site quota automatically

Microsoft

Following a customer request, I've created the following script to help you set the site quota automatically for newly created groups. You could easily wrap the following script sample into a daily timer job.

 

#...................................
# Variables:
# Cut off date in days
# Storage quota in MB
# Storage quota warning level in MB
#...................................
$cutoffdate = ((Get-Date).AddDays(-20))
$quota = 500
$warning = 400

# Retrieve recently created groups
$Groups = Get-UnifiedGroup | Where-Object {$_.WhenCreated -ge $cutoffdate} | Sort-Object whencreated | Select DisplayName, WhenCreated, SharePointSiteUrl

# For each new group update quota accordinly if a team site exists.
ForEach ($G in $Groups) {
try
{
Set-SPOSite –Identity ($G.SharePointSiteUrl) -StorageQuota $quota -StorageQuotaWarningLevel $warning
Write-Host "The following site quota was updated:" $G.SharePointSiteUrl
}
catch
{
Write-Host "The following Groups does have a site:" $G.DisplayName
}
}

0 Replies