This Powsershell will set every OneDrive for Business quota to the minimum set below

# This Powsershell will set every OneDrive for Business quota to the minimum set below.
# Quota's that are above the minimum are not changed.
# Richard Artes January 2010
#

# Set the location of the Log file here:
 $LogFile = "c:\temp\quotaSetMinList.txt"

# Set the new minimum GB quota here:
 $minQuota = 100
 $newQuotaMB= $minQuota * 1024

#Your Sharepoint/OneDrive URL goes here:
 Connect-SPOService -Url "https://xxxxxxxxxxxxxxxxxxxxx.sharepoint.com/"

 $oneDriveSites = Get-SPOSite -IncludePersonalSite $true -Limit all -Filter "Url -like '-my.sharepoint.com/personal/'"
 $oneDriveSites | ForEach-Object {
 $site = $_

 $strUserDetails = Get-SPOSite –Identity $site

 # If you want to see what every site's quota is before changes, uncomment this:
 #Out-File -FilePath $LogFile -InputObject $strUserDetails -Encoding UTF8 -append

$QuotaGB = ($strUserDetails.StorageQuota / 1024)

If($QuotaGB -lt $minQuota)
{
Out-File -FilePath $LogFile -InputObject "----User has a quota less than minimum--------" -Encoding UTF8 -append
Out-File -FilePath $LogFile -InputObject $site -Encoding UTF8 -append

$text = "New Quota = " + $newQuotaMB
Out-File -FilePath $LogFile -InputObject $text -Encoding UTF8 -append

Set-SPOSite –Identity $site -StorageQuota $newQuotaMB -Confirm

Out-File -FilePath $LogFile -InputObject "-----         New quota set.          --------" -Encoding UTF8 -append
}
}

 Write-Host "Done! File saved as $($LogFile)."

Comments

Popular posts from this blog

"The SNMP Service is ignoring the manager because its name could not be resolved." in Windows Server Event log.

Server Manager will not start, error .NET Framework: "This application requires one of the following versions of the .NET Framework:"