Skip to content

Instantly share code, notes, and snippets.

@peplau
Created January 10, 2025 20:59
Show Gist options
  • Save peplau/166c204ad243b8ac8e76cc1b856617a0 to your computer and use it in GitHub Desktop.
Save peplau/166c204ad243b8ac8e76cc1b856617a0 to your computer and use it in GitHub Desktop.
Know your Media Library disk usage with a simple PowerShell script
# Define your Media Library path - With no changes, this will take the full Media Library
$mediaLibraryPath = "/sitecore/media library"
$mediaLibrary = Get-Item -Path $mediaLibraryPath
$totalSize = 0
$mediaLibrary | Get-ChildItem -Recurse | ForEach-Object {
if ($_.Fields["Size"] -ne $null -and $_.Fields["Size"].Value.Trim() -ne "") {
$totalSize += $_.Fields["Size"].Value
}
}
# Output the used disk space
$totalSizeMB = [math]::Round($totalSize / 1MB, 2)
Write-Output "Total Media Library Size: $totalSizeMB MB"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment