Script to Calculate Folder Sizes PowerShell

$volumePath = "C:\"  # Replace this with the path of the volume root you want to analyze

# Get all directories at the root of the volume
$directories = Get-ChildItem -Path $volumePath -Directory

# Calculate size for each directory
foreach ($dir in $directories) {
    $dirSize = (Get-ChildItem -Path $dir.FullName -Recurse -ErrorAction SilentlyContinue | Measure-Object -Property Length -Sum -ErrorAction SilentlyContinue).Sum
    $dirSizeGB = [math]::Round($dirSize / 1GB, 2)  # Convert bytes to gigabytes
    Write-Output "$($dir.Name) - $dirSizeGB GB"
}
  • Script to Calculate Folder Sizes PowerShell, Script to Calculate Folder Sizes, Calculate Folder Sizes
  • 0 Korisnici koji smatraju članak korisnim
Je li Vam ovaj odgovor pomogao?

Vezani članci

Get the free space and total size of each drive in gigabytes using PowerShell

To accurately get the free space and total size of each drive in gigabytes using PowerShell, you...

.ps1 cannot be loaded because the execution of scripts is disabled on this system

  We need to run the following command: Set-ExecutionPolicy -scope CurrentUser Unrestricted