Monday, July 22, 2024
HomePowershellLearn how to set OneDrive Quotas with PowerShell – SID-500.COM

Learn how to set OneDrive Quotas with PowerShell – SID-500.COM

Microsoft 365

On this weblog publish I’ll present you how you can set OneDrive quotas with PowerShell. I’d say right here we go!

First, let’s hook up with SharePoint On-line. Ensure you enter the proper URL and the proper person account.

Set up-Module -Identify Microsoft.On-line.SharePoint.PowerShell -Pressure -AllowClobber
$cred = Get-Credential -Credential
Join-SPOService -Url -Credential $cred

Subsequent, we have to determine the URLs.

# Discover out all OneDrive URLs  
$LogFile = [Environment]::GetFolderPath("Desktop") + "OneDriveSites.log"
Get-SPOSite -IncludePersonalSite $true -Restrict all -Filter "Url -like ''" | 
Choose-Object -ExpandProperty Url | Tee-object -FilePath $LogFile
Write-Host "File saved as $($LogFile)."

As soon as we now have the URL, we will use it to set quotas.

# Configure OneDrive Quota per Consumer
$OneDriveSite = "" 
$OneDriveStorageQuota = "2097152" # MB
$OneDriveStorageQuotaWarningLevel = "1000000" # MB
Set-SPOSite -Identification $OneDriveSite -StorageQuota $OneDriveStorageQuota -StorageQuotaWarningLevel $OneDriveStorageQuotaWarningLevel 
Write-Host "Achieved"

That’s it. Now we have set a OneDrive quota for a person.

However now we’re attending to the actual deal. With the file generated above, we will set quotas for all customers, . That is known as automation.

# Automation
$urls = Get-Content material $homedesktopOneDriveSites.log
$OneDriveStorageQuota = "2097152" # MB
$OneDriveStorageQuotaWarningLevel = "1000000" # MB
foreach ($u in $urls) {
    Set-SPOSite -Identification $u -StorageQuota $OneDriveStorageQuota -StorageQuotaWarningLevel $OneDriveStorageQuotaWarningLevel 

That’s what I needed to indicate on this publish. I hope it was useful.

Revealed by Patrick Gruenauer

Microsoft MVP on PowerShell [2018-2024], IT-Coach, IT-Marketing consultant, MCSE: Cloud Platform and Infrastructure, Cisco Licensed Academy Teacher.



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments