Microsoft 365: PowerShell ile OneDrive Kotaları nasıl ayarlanır?


Bu blog yazısında size PowerShell ile OneDrive kotalarını nasıl ayarlayacağınızı göstereceğim. İşte başlıyoruz derdim!

Öncelikle SharePoint Online’a bağlanalım. Doğru URL'yi ve doğru kullanıcı hesabını girdiğinizden emin olun.

Install-Module -Name Microsoft.Online.SharePoint.PowerShell -Force -AllowClobber
$cred = Get-Credential -Credential patrick@m365ps2022.onmicrosoft.com
Connect-SPOService -Url https://m365ps2022-admin.sharepoint.com -Credential $cred

Daha sonra URL'leri bulmamız gerekiyor.

# Find out all OneDrive URLs  
$LogFile = [Environment]::GetFolderPath("Desktop") + "\OneDriveSites.log"
Get-SPOSite -IncludePersonalSite $true -Limit all -Filter "Url -like '-my.sharepoint.com/personal/'" | 
Select-Object -ExpandProperty Url | Tee-object -FilePath $LogFile
Write-Host "File saved as $($LogFile)."

URL'yi aldıktan sonra kotaları ayarlamak için kullanabiliriz.

# Configure OneDrive Quota per User
$OneDriveSite = "https://m365ps2022-my.sharepoint.com/personal/f_bizeps_m365ps2022_onmicrosoft_com" 
$OneDriveStorageQuota = "2097152" # MB
$OneDriveStorageQuotaWarningLevel = "1000000" # MB
Set-SPOSite -Identity $OneDriveSite -StorageQuota $OneDriveStorageQuota -StorageQuotaWarningLevel $OneDriveStorageQuotaWarningLevel 
Write-Host "Done"

Bu kadar. Bir kullanıcı için OneDrive kotası belirledik.

Ama şimdi asıl meseleye geliyoruz. Yukarıda oluşturduğumuz dosya ile tüm kullanıcılara aynı anda kota belirleyebiliyoruz. Buna otomasyon denir.

# Automation
$urls = Get-Content $home\desktop\OneDriveSites.log
$OneDriveStorageQuota = "2097152" # MB
$OneDriveStorageQuotaWarningLevel = "1000000" # MB
foreach ($u in $urls) {
    Set-SPOSite -Identity $u -StorageQuota $OneDriveStorageQuota -StorageQuotaWarningLevel $OneDriveStorageQuotaWarningLevel 
}

Bu yazıda göstermek istediğim şey buydu. Umarım faydalı olmuştur.

İlgili makaleler