Created
January 10, 2025 20:59
-
-
Save peplau/166c204ad243b8ac8e76cc1b856617a0 to your computer and use it in GitHub Desktop.
Know your Media Library disk usage with a simple PowerShell script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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